aboutsummaryrefslogblamecommitdiffhomepage
path: root/src/PursLoader/Options.purs
blob: 0c1453e10a608f540ca406072bdb1d38ad254bea (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 { 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"