@@ -12,6 +12,7 @@ process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.e
12
12
process . env . FOO = 'foo' ;
13
13
14
14
const TIMEOUT_REGEXP = / t i m e d o u t a f t e r / ;
15
+ const ENOENT_REGEXP = process . platform === 'win32' ? / f a i l e d w i t h e x i t c o d e 1 / : / s p a w n .* E N O E N T / ;
15
16
16
17
test ( 'execa()' , async t => {
17
18
const { stdout} = await execa ( 'noop' , [ 'foo' ] ) ;
@@ -75,7 +76,7 @@ test('execa.sync()', t => {
75
76
test ( 'execa.sync() throws error if written to stderr' , t => {
76
77
t . throws ( ( ) => {
77
78
execa . sync ( 'foo' ) ;
78
- } , process . platform === 'win32' ? / f a i l e d w i t h e x i t c o d e 1 / : / s p a w n S y n c f o o E N O E N T / ) ;
79
+ } , ENOENT_REGEXP ) ;
79
80
} ) ;
80
81
81
82
test ( 'skip throwing when using reject option' , async t => {
@@ -181,15 +182,21 @@ test('stripFinalNewline in sync mode on failure', t => {
181
182
t . is ( stderr , 'foo' ) ;
182
183
} ) ;
183
184
184
- test ( 'preferLocal option' , async t => {
185
- await execa ( 'ava' , [ '--version' ] , { env : { PATH : '' } } ) ;
186
- const errorRegExp = process . platform === 'win32' ? / f a i l e d w i t h e x i t c o d e 1 / : / s p a w n a v a E N O E N T / ;
187
- await t . throwsAsync ( execa ( 'ava' , [ '--version' ] , { preferLocal : false , env : { PATH : '' } } ) , errorRegExp ) ;
185
+ test ( 'preferLocal: true' , async t => {
186
+ await t . notThrowsAsync ( execa ( 'ava' , [ '--version' ] , { preferLocal : true , env : { PATH : '' } } ) ) ;
187
+ } ) ;
188
+
189
+ test ( 'preferLocal: false' , async t => {
190
+ await t . throwsAsync ( execa ( 'ava' , [ '--version' ] , { preferLocal : false , env : { PATH : '' } } ) , ENOENT_REGEXP ) ;
191
+ } ) ;
192
+
193
+ test ( 'preferLocal: undefined' , async t => {
194
+ await t . throwsAsync ( execa ( 'ava' , [ '--version' ] , { env : { PATH : '' } } ) , ENOENT_REGEXP ) ;
188
195
} ) ;
189
196
190
197
test ( 'localDir option' , async t => {
191
198
const command = process . platform === 'win32' ? 'echo %PATH%' : 'echo $PATH' ;
192
- const { stdout} = await execa ( command , { shell : true , localDir : '/test' } ) ;
199
+ const { stdout} = await execa ( command , { shell : true , preferLocal : true , localDir : '/test' } ) ;
193
200
const envPaths = stdout . split ( path . delimiter ) . map ( envPath =>
194
201
envPath . replace ( / \\ / g, '/' ) . replace ( / ^ [ ^ / ] + / , '' )
195
202
) ;
0 commit comments