Release 0.1.3.1
* Upgrade code to run with base 4.16 * Stop using cabal-generated module * Fix sjw not returning with exit code 1 on errors
This commit is contained in:
parent
db7b0b5d89
commit
d6553047d6
6 changed files with 36 additions and 29 deletions
|
@ -1,5 +1,11 @@
|
||||||
# Revision history for SJW
|
# Revision history for SJW
|
||||||
|
|
||||||
|
## 0.1.3.1 -- 2023-03-14
|
||||||
|
|
||||||
|
* Upgrade code to run with base 4.16
|
||||||
|
* Stop using cabal-generated module
|
||||||
|
* Fix sjw not returning with exit code 1 on errors
|
||||||
|
|
||||||
## 0.1.3.0 -- 2022-08-09
|
## 0.1.3.0 -- 2022-08-09
|
||||||
|
|
||||||
* Add support for disjunct package folders
|
* Add support for disjunct package folders
|
||||||
|
|
|
@ -3,7 +3,7 @@ cabal-version: 2.4
|
||||||
-- further documentation, see http://haskell.org/cabal/users-guide/
|
-- further documentation, see http://haskell.org/cabal/users-guide/
|
||||||
|
|
||||||
name: SJW
|
name: SJW
|
||||||
version: 0.1.3.0
|
version: 0.1.3.1
|
||||||
synopsis: The Simple Javascript Wrench
|
synopsis: The Simple Javascript Wrench
|
||||||
description:
|
description:
|
||||||
SJW is a very simple tool to pack several JS modules into a single script.
|
SJW is a very simple tool to pack several JS modules into a single script.
|
||||||
|
@ -35,7 +35,7 @@ library
|
||||||
, SJW.Module.Imports
|
, SJW.Module.Imports
|
||||||
, SJW.Source
|
, SJW.Source
|
||||||
build-depends: attoparsec >= 0.13.2 && < 0.15
|
build-depends: attoparsec >= 0.13.2 && < 0.15
|
||||||
, base >=4.9 && <4.16
|
, base >=4.9 && <4.17
|
||||||
, containers >= 0.5.0 && < 0.7
|
, containers >= 0.5.0 && < 0.7
|
||||||
, directory >= 1.2.0 && < 1.4
|
, directory >= 1.2.0 && < 1.4
|
||||||
, filepath >= 1.4.2 && < 1.5
|
, filepath >= 1.4.2 && < 1.5
|
||||||
|
@ -50,8 +50,6 @@ library
|
||||||
|
|
||||||
executable sjw
|
executable sjw
|
||||||
main-is: src/Main.hs
|
main-is: src/Main.hs
|
||||||
other-modules: Paths_SJW
|
|
||||||
autogen-modules: Paths_SJW
|
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
build-depends: attoparsec
|
build-depends: attoparsec
|
||||||
, base
|
, base
|
||||||
|
|
|
@ -19,10 +19,11 @@
|
||||||
{-# LANGUAGE NamedFieldPuns #-}
|
{-# LANGUAGE NamedFieldPuns #-}
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import SJW (Path(..), compile, source, sourceCode)
|
import SJW (Path(..), compile, source)
|
||||||
import Control.Monad (foldM)
|
import Control.Monad (foldM)
|
||||||
import Data.Time.Clock (diffUTCTime, getCurrentTime)
|
import Data.Time.Clock (diffUTCTime, getCurrentTime)
|
||||||
import System.Directory (createDirectoryIfMissing, doesDirectoryExist)
|
import System.Directory (createDirectoryIfMissing, doesDirectoryExist)
|
||||||
|
import System.Exit (die)
|
||||||
import System.FilePath ((</>), (<.>))
|
import System.FilePath ((</>), (<.>))
|
||||||
import System.Random (randomRIO)
|
import System.Random (randomRIO)
|
||||||
import Text.Printf (printf)
|
import Text.Printf (printf)
|
||||||
|
@ -107,7 +108,14 @@ main = do
|
||||||
generateDAG 10000 10 (50, 100) >>= mapM_ writeFakeModule
|
generateDAG 10000 10 (50, 100) >>= mapM_ writeFakeModule
|
||||||
else return ()
|
else return ()
|
||||||
start <- getCurrentTime
|
start <- getCurrentTime
|
||||||
maybe (return ()) (\_ -> return ()) =<< sourceCode =<< compile (source [destDir])
|
compile (source [destDir]) >>= either fails (succeeds start)
|
||||||
|
where
|
||||||
|
fails errorMsg = die $
|
||||||
|
printf
|
||||||
|
"%s\nThe benchmark crashed and failed to compile the modules generated in %s"
|
||||||
|
errorMsg
|
||||||
|
destDir
|
||||||
|
succeeds start _ = do
|
||||||
end <- getCurrentTime
|
end <- getCurrentTime
|
||||||
mapM_ putStrLn [
|
mapM_ putStrLn [
|
||||||
"Compiled 10k modules in " ++ show (diffUTCTime end start)
|
"Compiled 10k modules in " ++ show (diffUTCTime end start)
|
||||||
|
|
22
src/Main.hs
22
src/Main.hs
|
@ -24,14 +24,18 @@ import Control.Applicative (many, optional)
|
||||||
#if !MIN_VERSION_base(4,11,0)
|
#if !MIN_VERSION_base(4,11,0)
|
||||||
import Data.Monoid ((<>))
|
import Data.Monoid ((<>))
|
||||||
#endif
|
#endif
|
||||||
import qualified Data.Text as Text (unpack)
|
import qualified Data.Text.IO as Text (putStr, writeFile)
|
||||||
import Data.Version (showVersion)
|
import Data.Version (Version(..), showVersion)
|
||||||
import Options.Applicative (
|
import Options.Applicative (
|
||||||
Parser, execParser, fullDesc, info, header, help, helper, long, metavar
|
Parser, execParser, fullDesc, info, header, help, helper, long, metavar
|
||||||
, short, strArgument, strOption, value
|
, short, strArgument, strOption, value
|
||||||
)
|
)
|
||||||
import Paths_SJW (version)
|
import SJW (Source, compile, mainIs, source)
|
||||||
import SJW (Source, compile, mainIs, source, sourceCode)
|
import System.Exit (die)
|
||||||
|
import System.IO (stderr, hPutStrLn)
|
||||||
|
|
||||||
|
version :: Version
|
||||||
|
version = Version [0, 1, 3, 1] []
|
||||||
|
|
||||||
data Config = Config {
|
data Config = Config {
|
||||||
includes :: [String]
|
includes :: [String]
|
||||||
|
@ -81,10 +85,8 @@ getSource (Config {includes, mainModuleName = Just moduleName, target}) =
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
config@(Config {outputFile}) <- getConfig
|
config@(Config {outputFile}) <- getConfig
|
||||||
result <- SJW.sourceCode =<< SJW.compile (getSource config)
|
SJW.compile (getSource config) >>= either die (logAnd (write outputFile))
|
||||||
case result of
|
|
||||||
Nothing -> return ()
|
|
||||||
Just code -> output outputFile $ Text.unpack code
|
|
||||||
where
|
where
|
||||||
output "-" = putStr
|
logAnd f (a, logs) = mapM_ (hPutStrLn stderr) logs *> f a
|
||||||
output fileName = writeFile fileName
|
write "-" = Text.putStr
|
||||||
|
write fileName = Text.writeFile fileName
|
||||||
|
|
|
@ -24,7 +24,6 @@ module SJW (
|
||||||
, compile
|
, compile
|
||||||
, mainIs
|
, mainIs
|
||||||
, source
|
, source
|
||||||
, sourceCode
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Applicative ((<|>))
|
import Control.Applicative ((<|>))
|
||||||
|
@ -41,7 +40,6 @@ import SJW.Source (CodePath(..), Source(..), Path(..), source)
|
||||||
import System.Directory (doesDirectoryExist)
|
import System.Directory (doesDirectoryExist)
|
||||||
import System.Environment (lookupEnv)
|
import System.Environment (lookupEnv)
|
||||||
import System.FilePath ((</>))
|
import System.FilePath ((</>))
|
||||||
import System.IO (stderr, hPutStrLn)
|
|
||||||
import System.Posix.User (getRealUserID, getUserEntryForID, homeDirectory)
|
import System.Posix.User (getRealUserID, getUserEntryForID, homeDirectory)
|
||||||
import Text.Printf (printf)
|
import Text.Printf (printf)
|
||||||
|
|
||||||
|
@ -58,11 +56,6 @@ compile inputSource = runExceptT $ do
|
||||||
modules = Map.empty
|
modules = Map.empty
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCode :: Result -> IO (Maybe Text)
|
|
||||||
sourceCode (Left errorMessage) = hPutStrLn stderr errorMessage >> return Nothing
|
|
||||||
sourceCode (Right (output, logs)) =
|
|
||||||
mapM_ (hPutStrLn stderr) logs >> return (Just output)
|
|
||||||
|
|
||||||
mainIs :: Source -> String -> Source
|
mainIs :: Source -> String -> Source
|
||||||
mainIs context dotSeparated = context {mainModule = read dotSeparated}
|
mainIs context dotSeparated = context {mainModule = read dotSeparated}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue