From 002439ef93ddef31170dbf0361ddc89d2b02eee8 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Mon, 17 Jan 2022 19:02:52 +0300 Subject: [PATCH] fix: add `preferLocal` option to allow execa to use local npm version (#445) Co-authored-by: Matt Travi --- lib/add-channel.js | 1 + lib/prepare.js | 2 +- lib/publish.js | 2 +- lib/verify-auth.js | 6 +++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/add-channel.js b/lib/add-channel.js index ccb39814..00db5612 100644 --- a/lib/add-channel.js +++ b/lib/add-channel.js @@ -24,6 +24,7 @@ module.exports = async (npmrc, {npmPublish}, pkg, context) => { { cwd, env, + preferLocal: true, } ); result.stdout.pipe(stdout, {end: false}); diff --git a/lib/prepare.js b/lib/prepare.js index 25fb8ee1..4ec52b95 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -22,7 +22,7 @@ module.exports = async (npmrc, {tarballDir, pkgRoot}, {cwd, env, stdout, stderr, if (tarballDir) { logger.log('Creating npm package version %s', version); - const packResult = execa('npm', ['pack', basePath, '--userconfig', npmrc], {cwd, env}); + const packResult = execa('npm', ['pack', basePath, '--userconfig', npmrc], {cwd, env, preferLocal: true}); packResult.stdout.pipe(stdout, {end: false}); packResult.stderr.pipe(stderr, {end: false}); diff --git a/lib/publish.js b/lib/publish.js index c79d5652..ff3af007 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -23,7 +23,7 @@ module.exports = async (npmrc, {npmPublish, pkgRoot}, pkg, context) => { const result = execa( 'npm', ['publish', basePath, '--userconfig', npmrc, '--tag', distTag, '--registry', registry], - {cwd, env} + {cwd, env, preferLocal: true} ); result.stdout.pipe(stdout, {end: false}); result.stderr.pipe(stderr, {end: false}); diff --git a/lib/verify-auth.js b/lib/verify-auth.js index d4605632..bd7efc08 100644 --- a/lib/verify-auth.js +++ b/lib/verify-auth.js @@ -18,7 +18,11 @@ module.exports = async (npmrc, pkg, context) => { if (normalizeUrl(registry) === normalizeUrl(DEFAULT_NPM_REGISTRY)) { try { - const whoamiResult = execa('npm', ['whoami', '--userconfig', npmrc, '--registry', registry], {cwd, env}); + const whoamiResult = execa('npm', ['whoami', '--userconfig', npmrc, '--registry', registry], { + cwd, + env, + preferLocal: true, + }); whoamiResult.stdout.pipe(stdout, {end: false}); whoamiResult.stderr.pipe(stderr, {end: false}); await whoamiResult;