From 1d2c989ecbb04e543a26c303413a2047a2083a43 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 7 May 2019 12:15:03 +0200 Subject: [PATCH 1/3] Improve test for `options.localDir` --- test.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/test.js b/test.js index 2cb309534..9712e88b8 100644 --- a/test.js +++ b/test.js @@ -199,15 +199,12 @@ 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 [firstPath] = stdout.split(path.delimiter); + const firstUnixPath = firstPath.replace(/\\/g, '/').replace(/^[^/]+/, ''); + t.is(firstUnixPath, '/test/node_modules/.bin'); }); test('input option can be a String', async t => { From 6cac6b614351d3a85bef3b7d4631cb3230b7d79c Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 7 May 2019 12:30:30 +0200 Subject: [PATCH 2/3] Try fixing test --- test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test.js b/test.js index 9712e88b8..792646368 100644 --- a/test.js +++ b/test.js @@ -202,9 +202,10 @@ test.serial('preferLocal option', async t => { test('localDir option', async t => { const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH'; const {stdout} = await execa(command, {shell: true, localDir: '/test'}); - const [firstPath] = stdout.split(path.delimiter); - const firstUnixPath = firstPath.replace(/\\/g, '/').replace(/^[^/]+/, ''); - t.is(firstUnixPath, '/test/node_modules/.bin'); + 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 => { From 77c8c63d4db99429fe001e7493a1bbfc94ad573b Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 7 May 2019 13:19:53 +0200 Subject: [PATCH 3/3] Remove fixture file --- fixtures/local-dir/package.json | 5 ----- 1 file changed, 5 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" - } -}