aboutsummaryrefslogblamecommitdiffhomepage
path: root/src/PursLoader/Options.purs
blob: 132096c5d6ba73a5486ecc3706c46c49fac552b9 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                         

              

         
                                 
 


                                                        
 
                                 
 
                                                 
 
                                       
 

                                      
 
                                                    








                                                                                              
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 { pscBundle :: String }

type Options_ = { pscBundle :: String }

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

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

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