]>
Commit | Line | Data |
---|---|---|
c194f84c | 1 | module PursLoader.Options |
46039343 | 2 | ( Options(..) |
63d6a244 | 3 | , runOptions |
c194f84c | 4 | ) where |
5 | ||
63d6a244 | 6 | import Prelude ((<$>), (<<<), id) |
03b840cb | 7 | |
63d6a244 | 8 | import Data.Foreign.Class (IsForeign, readProp) |
9 | import Data.Foreign.NullOrUndefined (runNullOrUndefined) | |
10 | import Data.Maybe (maybe) | |
c194f84c | 11 | |
63d6a244 | 12 | import PursLoader.Path (joinPath) |
c194f84c | 13 | |
d7811214 | 14 | newtype Options = Options { bundleOutput :: String } |
c194f84c | 15 | |
d7811214 | 16 | type Options_ = { bundleOutput :: String } |
c194f84c | 17 | |
63d6a244 | 18 | runOptions :: Options -> Options_ |
19 | runOptions (Options options) = options | |
2b620717 | 20 | |
c194f84c | 21 | instance isForeignOptions :: IsForeign Options where |
63d6a244 | 22 | read obj = |
d7811214 | 23 | Options <$> ({ bundleOutput: _ } |
24 | <$> (maybe bundleOutputDefault id <<< runNullOrUndefined <$> readProp bundleOutput obj)) | |
63d6a244 | 25 | where |
d7811214 | 26 | bundleOutput :: String |
27 | bundleOutput = "bundleOutput" | |
63d6a244 | 28 | |
d7811214 | 29 | bundleOutputDefault :: String |
30 | bundleOutputDefault = joinPath "output" "bundle.js" |