snaplet-purescript 0.5.2.0 → 0.5.2.3
raw patch · 3 files changed
+36/−7 lines, 3 filesdep ~snapnew-uploader
Dependency ranges changed: snap
Files
- snaplet-purescript.cabal +4/−2
- src/Snap/Snaplet/PureScript.hs +28/−4
- src/Snap/Snaplet/PureScript/Internal.hs +4/−1
snaplet-purescript.cabal view
@@ -1,5 +1,5 @@ name: snaplet-purescript-version: 0.5.2.0+version: 0.5.2.3 synopsis: Automatic (re)compilation of purescript projects description: Automatic (re)compilation of purescript projects license: MIT@@ -23,7 +23,7 @@ Paths_snaplet_purescript build-depends: base >=4.6 && < 5.1, snap-core < 1.1.0.0,- snap < 1.1.0.0,+ snap >= 1.1.2.0, raw-strings-qq >= 1.0.2, string-conv, text > 0.11 && < 1.4.0.0,@@ -33,4 +33,6 @@ shelly >= 0.4.1 hs-source-dirs: src+ ghc-options:+ -Wall default-language: Haskell2010
src/Snap/Snaplet/PureScript.hs view
@@ -28,7 +28,6 @@ import Text.Printf import Text.RawString.QQ - -------------------------------------------------------------------------------- -- | Snaplet initialization initPurs :: SnapletInit b PureScript@@ -52,6 +51,8 @@ verbosity <- liftIO (lookupDefault Verbose config "verbosity") bndl <- liftIO (lookupDefault True config "bundle") bundleName <- liftIO (lookupDefault "app.js" config "bundleName")+ bundleExe <- liftIO (lookupDefault "psc-bundle" config "bundleExe")+ bundleOpts <- liftIO (lookupDefault mempty config "bundleOpts") modules <- liftIO (lookupDefault ["Main"] config "modules") psPath <- liftIO (lookupDefault mempty config "pureScriptPath") pulpPath <- findOrInstallPulp psPath =<< liftIO (Cfg.lookup config "pulpPath")@@ -72,6 +73,8 @@ , pursVerbosity = verbosity , pursBundle = bndl , pursBundleName = bundleName+ , pursBundleExe = bundleExe+ , pursBundleOpts = bundleOpts , pursPulpPath = pulpPath , pursPsPath = psPath , pursPsaOpts = psaOpts@@ -152,15 +155,28 @@ True -> do preBundleHook pursHooks rm_rf (fromText bundlePath)- let modules = T.intercalate " -m " pursModules echo $ "Bundling everything in " <> bundlePath- res <- run "psc-bundle" (["js/**/*.js", "-m"] <> (T.words modules) <>- ["-o", bundlePath, "-n", "PS"])+ res <- case (pursBundleExe, pursBundleOpts) of+ ("psc-bundle", []) ->+ let modules = T.intercalate " -m " pursModules+ pscBundlExe = maybeM "psc-bundle" (\x -> x <> "/" <> "psc-bundle") pursPsPath+ in run (fromText pscBundlExe) (["js/**/*.js", "-m"]+ <> (T.words modules)+ <> ["-o", bundlePath, "-n", "PS"])+ ("pulp", []) ->+ let modules = T.intercalate "," pursModules+ in run (fromString $ getPulpPath pursPulpPath) (["build", "-I", "src", "--modules"]+ <> (T.words modules)+ <> ["-t", bundlePath])+ (exe, args) -> run (fromText exe) args postBundleHook pursHooks eC <- lastExitCode case (eC == 0) of True -> return CompilationSucceeded False -> return $ CompilationFailed res+ where+ maybeM :: (Eq m, Monoid m) => m -> (m -> m) -> m -> m+ maybeM alt f x = if x == mempty then alt else f x -------------------------------------------------------------------------------- compileWithMode :: Handler b PureScript CompilationOutput@@ -213,6 +229,14 @@ # Whether bundle everything in a fat app # bundle = true+#+# Override the bundle command executable+#+bundleExe = "pulp"+#+# Override the bundle command arguments+#+bundleOpts = [] # # The path to a specific directory containing the purescript toolchain. # Example: snaplet/purs/node_modules/purescript/vendor.
src/Snap/Snaplet/PureScript/Internal.hs view
@@ -25,7 +25,6 @@ import Data.Configurator as Cfg import Data.Configurator.Types import Data.Maybe-import Data.Monoid import Data.String import Data.String.Conv import qualified Data.Text as T@@ -77,6 +76,10 @@ -- ^ Whether or not bundle everything in a fat app with a PS namespace. , pursBundleName :: !T.Text -- ^ The name for your bundled output.+ , pursBundleExe :: !T.Text+ -- ^ The name for the program used to bundle your app. (e.g. "pulp", "psc-bundle", etc)+ , pursBundleOpts :: ![T.Text]+ -- ^ Override the arguments passed to the bundle executable. , pursPulpPath :: !PulpPath -- ^ The absolute path to a `pulp` executable. This can be user-provided -- or inferred automatically by this snaplet.