@@ -13,6 +13,7 @@ import Node.Library.Execa as Execa
13
13
import Node.Platform as Platform
14
14
import Node.Process as Process
15
15
import Partial.Unsafe (unsafeCrashWith , unsafePartial )
16
+ import Unsafe.Coerce (unsafeCoerce )
16
17
17
18
data StdinConfig
18
19
= StdinPipeParent
@@ -77,6 +78,7 @@ type ExecOptions =
77
78
, pipeStdout :: Boolean
78
79
, pipeStderr :: Boolean
79
80
, cwd :: Maybe FilePath
81
+ , shell :: Boolean
80
82
}
81
83
82
84
defaultExecOptions :: ExecOptions
@@ -85,6 +87,7 @@ defaultExecOptions =
85
87
, pipeStdout: true
86
88
, pipeStderr: true
87
89
, cwd: Nothing
90
+ , shell: false
88
91
}
89
92
90
93
spawn :: forall m . MonadAff m => String -> Array String -> ExecOptions -> m Execa.ExecaProcess
@@ -94,7 +97,18 @@ spawn cmd args opts = liftAff do
94
97
StdinPipeParent -> Just inherit
95
98
StdinWrite _ -> Just pipe
96
99
StdinNewPipe -> Just pipe
97
- subprocess <- Execa .execa cmd args (_ { cwd = opts.cwd, stdin = stdinOpt, stdout = Just pipe, stderr = Just pipe })
100
+ subprocess <- Execa .execa cmd args
101
+ ( _
102
+ { cwd = opts.cwd
103
+ , stdin = stdinOpt
104
+ , stdout = Just pipe
105
+ , stderr = Just pipe
106
+ , shell = case opts.shell of
107
+ -- TODO: execa doesn't support the boolean option yet
108
+ true -> Just (unsafeCoerce true )
109
+ false -> Nothing
110
+ }
111
+ )
98
112
99
113
case opts.pipeStdin of
100
114
StdinWrite s | Just { writeUtf8End } <- subprocess.stdin -> writeUtf8End s
@@ -189,22 +203,22 @@ getExecutable command =
189
203
Just Platform.Win32 -> do
190
204
-- On Windows, we often need to call the `.cmd` version
191
205
let cmd1 = mkCmd command (Just " cmd" )
192
- askVersion cmd1 >>= case _ of
206
+ askVersion cmd1 true >>= case _ of
193
207
Right r -> pure { cmd: cmd1, output: r.stdout }
194
208
Left r -> do
195
209
let cmd2 = mkCmd command Nothing
196
210
logDebug [ " Failed to find purs.cmd. Trying with just purs..." , show r.message ]
197
- askVersion cmd2 >>= case _ of
211
+ askVersion cmd2 false >>= case _ of
198
212
Right r' -> pure { cmd: cmd2, output: r'.stdout }
199
213
Left r' -> complain r'
200
214
_ -> do
201
215
-- On other platforms, we just call `purs`
202
216
let cmd1 = mkCmd command Nothing
203
- askVersion cmd1 >>= case _ of
217
+ askVersion cmd1 false >>= case _ of
204
218
Right r -> pure { cmd: cmd1, output: r.stdout }
205
219
Left r -> complain r
206
220
where
207
- askVersion cmd = exec cmd [ " --version" ] defaultExecOptions { pipeStdout = false , pipeStderr = false }
221
+ askVersion cmd shell = exec cmd [ " --version" ] defaultExecOptions { pipeStdout = false , pipeStderr = false , shell = shell }
208
222
209
223
mkCmd cmd maybeExtension = cmd <> maybe " " (append " ." ) maybeExtension
210
224
0 commit comments