Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb22ff7

Browse files
ehmickysindresorhus
authored andcommitted
Change default value of thepreferLocal option tofalse (#314)
1 parent4dd258d commiteb22ff7

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

‎index.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare namespace execa {
2727
2828
If you `$ npm install foo`, you can then `execa('foo')`.
2929
30-
@defaulttrue
30+
@defaultfalse
3131
*/
3232
readonlypreferLocal?:boolean;
3333

‎index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const handleArgs = (file, args, options = {}) => {
2828
maxBuffer:DEFAULT_MAX_BUFFER,
2929
buffer:true,
3030
stripFinalNewline:true,
31-
preferLocal:true,
31+
preferLocal:false,
3232
localDir:options.cwd||process.cwd(),
3333
encoding:'utf8',
3434
reject:true,

‎readme.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Kill the spawned process when the parent process exits unless either:
281281
####preferLocal
282282

283283
Type:`boolean`<br>
284-
Default:`true`
284+
Default:`false`
285285

286286
Prefer locally installed binaries when looking for a binary to execute.<br>
287287
If you`$ npm install foo`, you can then`execa('foo')`.

‎test/test.js‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.e
1212
process.env.FOO='foo';
1313

1414
constTIMEOUT_REGEXP=/timedoutafter/;
15+
constENOENT_REGEXP=process.platform==='win32' ?/failedwithexitcode1/ :/spawn.*ENOENT/;
1516

1617
test('execa()',asynct=>{
1718
const{stdout}=awaitexeca('noop',['foo']);
@@ -75,7 +76,7 @@ test('execa.sync()', t => {
7576
test('execa.sync() throws error if written to stderr',t=>{
7677
t.throws(()=>{
7778
execa.sync('foo');
78-
},process.platform==='win32' ?/failedwithexitcode1/ :/spawnSyncfooENOENT/);
79+
},ENOENT_REGEXP);
7980
});
8081

8182
test('skip throwing when using reject option',asynct=>{
@@ -181,15 +182,21 @@ test('stripFinalNewline in sync mode on failure', t => {
181182
t.is(stderr,'foo');
182183
});
183184

184-
test('preferLocal option',asynct=>{
185-
awaitexeca('ava',['--version'],{env:{PATH:''}});
186-
consterrorRegExp=process.platform==='win32' ?/failedwithexitcode1/ :/spawnavaENOENT/;
187-
awaitt.throwsAsync(execa('ava',['--version'],{preferLocal:false,env:{PATH:''}}),errorRegExp);
185+
test('preferLocal: true',asynct=>{
186+
awaitt.notThrowsAsync(execa('ava',['--version'],{preferLocal:true,env:{PATH:''}}));
187+
});
188+
189+
test('preferLocal: false',asynct=>{
190+
awaitt.throwsAsync(execa('ava',['--version'],{preferLocal:false,env:{PATH:''}}),ENOENT_REGEXP);
191+
});
192+
193+
test('preferLocal: undefined',asynct=>{
194+
awaitt.throwsAsync(execa('ava',['--version'],{env:{PATH:''}}),ENOENT_REGEXP);
188195
});
189196

190197
test('localDir option',asynct=>{
191198
constcommand=process.platform==='win32' ?'echo %PATH%' :'echo $PATH';
192-
const{stdout}=awaitexeca(command,{shell:true,localDir:'/test'});
199+
const{stdout}=awaitexeca(command,{shell:true,preferLocal:true,localDir:'/test'});
193200
constenvPaths=stdout.split(path.delimiter).map(envPath=>
194201
envPath.replace(/\\/g,'/').replace(/^[^/]+/,'')
195202
);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp