From 0070738c23f71c7023027abc8c271f946ad4e683 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 7 May 2019 11:51:46 -0700 Subject: [PATCH] Fix test for `options.localDir` (#218) --- fixtures/local-dir/package.json | 5 ----- test.js | 16 +++++++--------- 2 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 fixtures/local-dir/package.json diff --git a/fixtures/local-dir/package.json b/fixtures/local-dir/package.json deleted file mode 100644 index 146cd6641..000000000 --- a/fixtures/local-dir/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "self-path": "^1.0.0" - } -} diff --git a/test.js b/test.js index c8a89214d..69c82348c 100644 --- a/test.js +++ b/test.js @@ -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 => {