@@ -12,6 +12,7 @@ process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.e
1212process . env . FOO = 'foo' ;
1313
1414const 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 / ;
1516
1617test ( 'execa()' , async t => {
1718const { stdout} = await execa ( 'noop' , [ 'foo' ] ) ;
@@ -75,7 +76,7 @@ test('execa.sync()', t => {
7576test ( 'execa.sync() throws error if written to stderr' , t => {
7677t . throws ( ( ) => {
7778execa . 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 ) ;
7980} ) ;
8081
8182test ( 'skip throwing when using reject option' , async t => {
@@ -181,15 +182,21 @@ test('stripFinalNewline in sync mode on failure', t => {
181182t . is ( stderr , 'foo' ) ;
182183} ) ;
183184
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 ) ;
188195} ) ;
189196
190197test ( 'localDir option' , async t => {
191198const 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' } ) ;
193200const envPaths = stdout . split ( path . delimiter ) . map ( envPath =>
194201envPath . replace ( / \\ / g, '/' ) . replace ( / ^ [ ^ / ] + / , '' )
195202) ;