From 88cbc8c447cbaef20b5a8f19246211ce4918f4d8 Mon Sep 17 00:00:00 2001 From: Gar Date: Thu, 6 May 2021 11:04:01 -0700 Subject: [PATCH] fix(tests): reflect new libnpmexec logic PR-URL: https://github.com/npm/cli/pull/3198 Credit: @wraithgar Close: #3198 Reviewed-by: @nlf, @darcyclarke --- test/lib/exec.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/lib/exec.js b/test/lib/exec.js index 5ecc73274876a..3d2da32a76675 100644 --- a/test/lib/exec.js +++ b/test/lib/exec.js @@ -121,11 +121,15 @@ t.afterEach(() => { t.test('npx foo, bin already exists locally', t => { const path = t.testdir({ - foo: 'just some file', + node_modules: { + '.bin': { + foo: 'just some file', + }, + }, }) PROGRESS_IGNORED = true - npm.localBin = path + npm.localBin = resolve(path, 'node_modules', '.bin') exec.exec(['foo', 'one arg', 'two arg'], er => { t.error(er, 'npm exec') @@ -137,7 +141,7 @@ t.test('npx foo, bin already exists locally', t => { stdioString: true, event: 'npx', env: { - PATH: [path, ...PATH].join(delimiter), + PATH: [npm.localBin, ...PATH].join(delimiter), }, stdio: 'inherit', }]) @@ -147,11 +151,15 @@ t.test('npx foo, bin already exists locally', t => { t.test('npx foo, bin already exists globally', t => { const path = t.testdir({ - foo: 'just some file', + node_modules: { + '.bin': { + foo: 'just some file', + }, + }, }) PROGRESS_IGNORED = true - npm.globalBin = path + npm.globalBin = resolve(path, 'node_modules', '.bin') exec.exec(['foo', 'one arg', 'two arg'], er => { t.error(er, 'npm exec') @@ -163,7 +171,7 @@ t.test('npx foo, bin already exists globally', t => { stdioString: true, event: 'npx', env: { - PATH: [path, ...PATH].join(delimiter), + PATH: [npm.globalBin, ...PATH].join(delimiter), }, stdio: 'inherit', }])