Skip to content

Commit

Permalink
Fix test for options.localDir (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored and sindresorhus committed May 7, 2019
1 parent 3e7ea99 commit 0070738
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
5 changes: 0 additions & 5 deletions fixtures/local-dir/package.json

This file was deleted.

16 changes: 7 additions & 9 deletions test.js
Expand Up @@ -190,15 +190,13 @@ test('preferLocal option', async t => {
await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {PATH: ''}}), errorRegExp);
});

test.serial('localDir option', async t => {
const cwd = 'fixtures/local-dir';
const bin = path.resolve(cwd, 'node_modules/.bin/self-path');

await execa('npm', ['install', '--no-package-lock'], {cwd});

const {stdout} = await execa(bin, {localDir: cwd});

t.is(path.relative(cwd, stdout), path.normalize('node_modules/self-path'));
test('localDir option', async t => {
const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH';
const {stdout} = await execa(command, {shell: true, localDir: '/test'});
const envPaths = stdout.split(path.delimiter).map(envPath =>
envPath.replace(/\\/g, '/').replace(/^[^/]+/, '')
);
t.true(envPaths.some(envPath => envPath === '/test/node_modules/.bin'));
});

test('input option can be a String', async t => {
Expand Down

0 comments on commit 0070738

Please sign in to comment.