aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PursLoader/Options.purs
blob: 0c1453e10a608f540ca406072bdb1d38ad254bea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module PursLoader.Options
  ( Options(..)
  , runOptions
  ) where

import Prelude ((<$>), (<<<), id)

import Data.Foreign.Class (IsForeign, readProp)
import Data.Foreign.NullOrUndefined (runNullOrUndefined)
import Data.Maybe (maybe)

import PursLoader.Path (joinPath)

newtype Options = Options { bundleOutput :: String }

type Options_ = { bundleOutput :: String }

runOptions :: Options -> Options_
runOptions (Options options) = options

instance isForeignOptions :: IsForeign Options where
  read obj =
    Options <$> ({ bundleOutput: _ }
            <$> (maybe bundleOutputDefault id <<< runNullOrUndefined <$> readProp bundleOutput obj))
    where
    bundleOutput :: String
    bundleOutput = "bundleOutput"

    bundleOutputDefault :: String
    bundleOutputDefault = joinPath "output" "bundle.js"