Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sindresorhus/execa
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 845e75f522ba4f8d5ebe2037e9fc3c1317568e62
Choose a base ref
..
head repository: sindresorhus/execa
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 69a85507ce46ae8a949419a00bf88f9da5f1b286
Choose a head ref
Showing with 4 additions and 6 deletions.
  1. +4 −6 test/test.js
10 changes: 4 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -73,22 +73,20 @@ test('stripFinalNewline in sync mode on failure', t => {
t.is(stderr, 'foo');
});

const pathKey = process.platform === 'win32' ? 'Path' : 'PATH';

test('preferLocal: true', async t => {
await t.notThrowsAsync(execa('ava', ['--version'], {preferLocal: true, env: {[pathKey]: ''}}));
await t.notThrowsAsync(execa('ava', ['--version'], {preferLocal: true, env: {Path: '', PATH: ''}}));
});

test('preferLocal: false', async t => {
await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {[pathKey]: ''}}), ENOENT_REGEXP);
await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {Path: '', PATH: ''}}), ENOENT_REGEXP);
});

test('preferLocal: undefined', async t => {
await t.throwsAsync(execa('ava', ['--version'], {env: {[pathKey]: ''}}), ENOENT_REGEXP);
await t.throwsAsync(execa('ava', ['--version'], {env: {Path: '', PATH: ''}}), ENOENT_REGEXP);
});

test('localDir option', async t => {
const command = process.platform === 'win32' ? `echo %${pathKey}%` : `echo $${pathKey}`;
const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH';
const {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: '/test'});
const envPaths = stdout.split(path.delimiter).map(envPath =>
envPath.replace(/\\/g, '/').replace(/^[^/]+/, '')