]> git.immae.eu Git - github/fretlink/purs-loader.git/blob - src/PursLoader/Options.purs
Updating bundle output option name
[github/fretlink/purs-loader.git] / src / PursLoader / Options.purs
1 module PursLoader.Options
2 ( Options()
3 , runOptions
4 ) where
5
6 import Prelude ((<$>), (<<<), id)
7
8 import Data.Foreign.Class (IsForeign, readProp)
9 import Data.Foreign.NullOrUndefined (runNullOrUndefined)
10 import Data.Maybe (maybe)
11
12 import PursLoader.Path (joinPath)
13
14 newtype Options = Options { bundleOutput :: String }
15
16 type Options_ = { bundleOutput :: String }
17
18 runOptions :: Options -> Options_
19 runOptions (Options options) = options
20
21 instance isForeignOptions :: IsForeign Options where
22 read obj =
23 Options <$> ({ bundleOutput: _ }
24 <$> (maybe bundleOutputDefault id <<< runNullOrUndefined <$> readProp bundleOutput obj))
25 where
26 bundleOutput :: String
27 bundleOutput = "bundleOutput"
28
29 bundleOutputDefault :: String
30 bundleOutputDefault = joinPath "output" "bundle.js"