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 2cb309534..792646368 100644 --- a/test.js +++ b/test.js @@ -199,15 +199,13 @@ test.serial('preferLocal option', async t => { process.env.PATH = _path; }); -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 => {