module Development.Shake.Elm ( elmMake
                             ) where

import           Development.Shake

-- | Rules for calling @elm-make@.
elmMake :: [FilePath] -- ^ Elm source files
        -> [FilePath] -- ^ Extra source files to be tracked
        -> FilePattern -- ^ Build output
        -> Rules ()
elmMake :: [FilePath] -> [FilePath] -> FilePath -> Rules ()
elmMake [FilePath]
sources [FilePath]
extras FilePath
fp =
    FilePath
fp Located => FilePath -> (FilePath -> Action ()) -> Rules ()
FilePath -> (FilePath -> Action ()) -> Rules ()
%> \FilePath
out -> do
        Located => [FilePath] -> Action ()
[FilePath] -> Action ()
need ([FilePath]
sources [FilePath] -> [FilePath] -> [FilePath]
forall a. Semigroup a => a -> a -> a
<> [FilePath]
extras)
        [CmdOption] -> FilePath -> [FilePath] -> Action ()
forall r.
(Located, CmdResult r) =>
[CmdOption] -> FilePath -> [FilePath] -> Action r
command [CmdOption]
forall a. Monoid a => a
mempty FilePath
"elm-make" (FilePath
"--yes" FilePath -> [FilePath] -> [FilePath]
forall a. a -> [a] -> [a]
: FilePath
"--output" FilePath -> [FilePath] -> [FilePath]
forall a. a -> [a] -> [a]
: FilePath
out FilePath -> [FilePath] -> [FilePath]
forall a. a -> [a] -> [a]
: FilePath
"--warn" FilePath -> [FilePath] -> [FilePath]
forall a. a -> [a] -> [a]
: [FilePath]
sources)