git.iko.soy/rowtype-yoga/purescript-native
on 24fdff2 help sign in
45 lines 1.4 kB history raw
1-----------------------------------------------------------------------------
2--
3-- Module : Main
4-- License : MIT (http://opensource.org/licenses/MIT)
5--
6-- Maintainer : Phil Freeman <paf31@cantab.net>
7-- Stability : experimental
8-- Portability :
9--
10-- |
11--
12-----------------------------------------------------------------------------
13module TestsSetup where
15import Prelude ()
16import Prelude.Compat
18import Data.Maybe (fromMaybe)
19import Control.Monad
20import Control.Monad.Trans.Maybe
22import System.Process
23import System.Directory
24import System.Info
26import Language.PureScript.Crash
28findNodeProcess :: IO (Maybe String)
29findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
30 where
31 names = ["nodejs", "node"]
33fetchSupportCode :: IO ()
34fetchSupportCode = do
35 node <- fromMaybe (internalError "cannot find node executable") <$> findNodeProcess
36 setCurrentDirectory "tests/support"
37 if System.Info.os == "mingw32"
38 then callProcess "setup-win.cmd" []
39 else do
40 callProcess "npm" ["install"]
41 -- Sometimes we run as a root (e.g. in simple docker containers)
42 -- And we are non-interactive: https://github.com/bower/bower/issues/1162
43 callProcess "node_modules/.bin/bower" ["--allow-root", "install", "--config.interactive=false"]
44 callProcess node ["setup.js"]
45 setCurrentDirectory "../.."