packages feed

hjsmin 0.1.4.4 → 0.1.4.5

raw patch · 3 files changed

+54/−5 lines, 3 filesdep +optparse-applicativedep ~basedep ~textnew-component:exe:hjsmin

Dependencies added: optparse-applicative

Dependency ranges changed: base, text

Files

README.markdown view
@@ -30,6 +30,10 @@ Changes ------- +0.1.4.5 - relax upper bound in text to support 1.1+        - introduce CLI wrapper for minifying files from the+          commandline, courtesy of @CodeBlock+ 0.1.4.4 - relax upper bound in text to support 1.0  0.1.4.3 - make sure all missing cases are covered@@ -60,7 +64,5 @@ 0.0.11 - Worked in language-javascript 0.4.*, with source locations in the AST          Worked in processing of property get/set in object literals 0.0.10 - Removed attoparsec dependency and historical Parse/Token--  
hjsmin.cabal view
@@ -1,5 +1,5 @@ name:            hjsmin-version:         0.1.4.4+version:         0.1.4.5 license:         BSD3 license-file:    LICENSE author:          Alan Zimmerman <alan.zimm@gmail.com>@@ -27,14 +27,25 @@     build-depends:   base                >= 4       && < 5                    , bytestring          >= 0.9     && < 0.11                    , blaze-builder       >= 0.2     && < 1-                   , text                >= 0.8     && < 1.1+                   , text                >= 0.8     && < 1.2                    , containers          >= 0.2     && < 0.6                    , language-javascript >= 0.5.1   && < 0.6     exposed-modules: Text.Jasmine     other-modules:   Text.Jasmine.Pretty     ghc-options:     -Wall +executable hjsmin+  main-is:             hjsmin.hs +  ghc-options:         -Wall -threaded+  build-depends:   base                 >= 4       && < 5+                 , bytestring           >= 0.9     && < 0.11+                 , blaze-builder        >= 0.2     && < 1+                 , text                 >= 0.8     && < 1.2+                 , containers           >= 0.2     && < 0.6+                 , language-javascript  >= 0.5.1   && < 0.6+                 , optparse-applicative >= 0.7     && < 0.8+ Test-Suite test-hjsmin   Type: exitcode-stdio-1.0   Main-is: runtests.hs@@ -46,7 +57,7 @@                  , base                >= 4       && < 5                  , bytestring          >= 0.9     && < 0.11                  , blaze-builder       >= 0.2     && < 1-                 , text                >= 0.8     && < 1+                 , text                >= 0.8     && < 1.2                  , containers          >= 0.2     && < 0.6                  , language-javascript >= 0.5.4   && < 0.6 
+ hjsmin.hs view
@@ -0,0 +1,36 @@+module Main where++import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Lazy.Char8 as C8+import Options.Applicative+import Text.Jasmine++data Options = Options {+    inputFile :: String+  , outputFile :: Maybe String+  }++options :: Parser Options+options = Options +      <$> argument str (metavar "INPUT_FILE"+                     <> help "The unminified, original JavaScript file")+      <*> optional (+            strOption (long "output-file"+                    <> short 'o'+                    <> metavar "OUTPUT_FILE"+                    <> help "The minified output file. Default: stdout"))++main :: IO ()+main = execParser opts >>= minify'+  where+    opts = info (helper <*> options)+      ( fullDesc+     <> progDesc "Minify JavaScript files."+     <> header "hjsmin - a simple command-line interface to the 'hjsmin' library" )++minify' :: Options -> IO ()+minify' o = do+  minified <- minifyFile (inputFile o)+  case outputFile o of+    Nothing -> C8.putStrLn $ minified+    Just f  -> B.writeFile f minified