git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1994 from purescript/utf-logging
cf11462Phil Freeman
psc-bundle/Main.hs+5−16
@@ -1,25 +1,12 @@
1−-----------------------------------------------------------------------------
2−--
3−-- Module : psc-bundle
4−-- Copyright : (c) Phil Freeman 2015
5−-- License : MIT
6−--
7−-- Maintainer : Phil Freeman <paf31@cantab.net>
8−-- Stability : experimental
9−-- Portability :
10−--
11−-- | Bundles compiled PureScript modules for the browser.
12−--
13−-----------------------------------------------------------------------------
14−
15{-# LANGUAGE FlexibleContexts #-}
1{-# LANGUAGE FlexibleContexts #-}
16{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
17{-# LANGUAGE TupleSections #-}
3{-# LANGUAGE TupleSections #-}
18{-# LANGUAGE RecordWildCards #-}
4{-# LANGUAGE RecordWildCards #-}
19
5
6+-- | Bundles compiled PureScript modules for the browser.
20module Main (main) where
7module Main (main) where
21
8
22−import Data.Maybe
9+import Data.Maybe
23import Data.Traversable (for)
10import Data.Traversable (for)
24import Data.Version (showVersion)
11import Data.Version (showVersion)
25
12
@@ -32,7 +19,7 @@ import Control.Monad.IO.Class
32import System.FilePath (takeFileName, takeDirectory)
19import System.FilePath (takeFileName, takeDirectory)
33import System.FilePath.Glob (glob)
20import System.FilePath.Glob (glob)
34import System.Exit (exitFailure)
21import System.Exit (exitFailure)
35−import System.IO (stderr, hPutStrLn)
22+import System.IO (stderr, stdout, hPutStrLn, hSetEncoding, utf8)
36import System.Directory (createDirectoryIfMissing)
23import System.Directory (createDirectoryIfMissing)
37
24
38import Language.PureScript.Bundle
25import Language.PureScript.Bundle
@@ -125,6 +112,8 @@ options = Options <$> some inputFile
125-- | Make it go.
112-- | Make it go.
126main :: IO ()
113main :: IO ()
127main = do
114main = do
115+ hSetEncoding stdout utf8
116+ hSetEncoding stderr utf8
128 opts <- execParser (info (version <*> helper <*> options) infoModList)
117 opts <- execParser (info (version <*> helper <*> options) infoModList)
129 when (isJust (optionsRequirePath opts)) $ hPutStrLn stderr "The require-path option is deprecated and will be removed in PureScript 0.9."
118 when (isJust (optionsRequirePath opts)) $ hPutStrLn stderr "The require-path option is deprecated and will be removed in PureScript 0.9."
130 output <- runExceptT (app opts)
119 output <- runExceptT (app opts)
psc-docs/Main.hs+5−15
@@ -1,17 +1,4 @@
1{-# LANGUAGE TupleSections #-}
1{-# LANGUAGE TupleSections #-}
2−----------------------------------------------------------------------------
3−--
4−-- Module : Main
5−-- Copyright : (c) Phil Freeman 2013
6−-- License : MIT
7−--
8−-- Maintainer : Phil Freeman <paf31@cantab.net>
9−-- Stability : experimental
10−-- Portability :
11−--
12−-- |
13−--
14−-----------------------------------------------------------------------------
15
2
16module Main where
3module Main where
17
4
@@ -32,7 +19,7 @@ import qualified Text.PrettyPrint.ANSI.Leijen as PP
32import qualified Language.PureScript as P
19import qualified Language.PureScript as P
33import qualified Paths_purescript as Paths
20import qualified Paths_purescript as Paths
34import System.Exit (exitFailure)
21import System.Exit (exitFailure)
35−import System.IO (hPutStrLn, hPrint, stderr)
22+import System.IO (hPutStrLn, hPrint, hSetEncoding, stderr, stdout, utf8)
36import System.Directory (createDirectoryIfMissing)
23import System.Directory (createDirectoryIfMissing)
37import System.FilePath (takeDirectory)
24import System.FilePath (takeDirectory)
38import System.FilePath.Glob (glob)
25import System.FilePath.Glob (glob)
@@ -228,7 +215,10 @@ buildOptions (fmt, input, mapping) =
228 exitFailure
215 exitFailure
229
216
230main :: IO ()
217main :: IO ()
218+main = do
219+ hSetEncoding stdout utf8
220+ hSetEncoding stderr utf8
231−main = execParser opts >>= buildOptions >>= docgen
221+ execParser opts >>= buildOptions >>= docgen
232 where
222 where
233 opts = info (version <*> helper <*> pscDocsOptions) infoModList
223 opts = info (version <*> helper <*> pscDocsOptions) infoModList
234 infoModList = fullDesc <> headerInfo <> footerInfo
224 infoModList = fullDesc <> headerInfo <> footerInfo
psc-publish/Main.hs+6−1
@@ -7,6 +7,8 @@ import qualified Data.ByteString.Lazy.Char8 as BL
7
7
8import Options.Applicative hiding (str)
8import Options.Applicative hiding (str)
9
9
10+import System.IO (hSetEncoding, stderr, stdout, utf8)
11+
10import qualified Paths_purescript as Paths
12import qualified Paths_purescript as Paths
11import Language.PureScript.Publish
13import Language.PureScript.Publish
12import Language.PureScript.Publish.ErrorsWarnings
14import Language.PureScript.Publish.ErrorsWarnings
@@ -24,7 +26,10 @@ dryRunOptions = defaultPublishOptions
24 where dummyVersion = ("0.0.0", Version [0,0,0] [])
26 where dummyVersion = ("0.0.0", Version [0,0,0] [])
25
27
26main :: IO ()
28main :: IO ()
29+main = do
30+ hSetEncoding stdout utf8
31+ hSetEncoding stderr utf8
27−main = execParser opts >>= publish
32+ execParser opts >>= publish
28 where
33 where
29 opts = info (version <*> helper <*> dryRun) infoModList
34 opts = info (version <*> helper <*> dryRun) infoModList
30 infoModList = fullDesc <> headerInfo <> footerInfo
35 infoModList = fullDesc <> headerInfo <> footerInfo
psc/Main.hs+5−16
@@ -1,17 +1,3 @@
1−-----------------------------------------------------------------------------
2−--
3−-- Module : Main
4−-- Copyright : (c) 2013-15 Phil Freeman, (c) 2014-15 Gary Burgess
5−-- License : MIT (http://opensource.org/licenses/MIT)
6−--
7−-- Maintainer : Phil Freeman <paf31@cantab.net>
8−-- Stability : experimental
9−-- Portability :
10−--
11−-- |
12−--
13−-----------------------------------------------------------------------------
14−
15{-# LANGUAGE DataKinds #-}
1{-# LANGUAGE DataKinds #-}
16{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
17{-# LANGUAGE RecordWildCards #-}
3{-# LANGUAGE RecordWildCards #-}
@@ -34,7 +20,7 @@ import qualified Data.ByteString.UTF8 as BU8
34import Options.Applicative as Opts
20import Options.Applicative as Opts
35
21
36import System.Exit (exitSuccess, exitFailure)
22import System.Exit (exitSuccess, exitFailure)
37−import System.IO (hPutStrLn, stderr)
23+import System.IO (hSetEncoding, hPutStrLn, stdout, stderr, utf8)
38import System.IO.UTF8
24import System.IO.UTF8
39import System.FilePath.Glob (glob)
25import System.FilePath.Glob (glob)
40
26
@@ -202,7 +188,10 @@ pscMakeOptions = PSCMakeOptions <$> many inputFile
202 <*> jsonErrors
188 <*> jsonErrors
203
189
204main :: IO ()
190main :: IO ()
191+main = do
192+ hSetEncoding stdout utf8
193+ hSetEncoding stderr utf8
205−main = execParser opts >>= compile
194+ execParser opts >>= compile
206 where
195 where
207 opts = info (version <*> helper <*> pscMakeOptions) infoModList
196 opts = info (version <*> helper <*> pscMakeOptions) infoModList
208 infoModList = fullDesc <> headerInfo <> footerInfo
197 infoModList = fullDesc <> headerInfo <> footerInfo