From b89415174519c50a561c2eb0e479c08ba8697c68 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 23 Nov 2020 21:26:54 -0800 Subject: [PATCH] build: update npx.py to support npx@7 (#26662) * build: update npx.py to support npx@7 * build: set npm_config_yes for all npx callsites --- script/codesign/generate-identity.sh | 2 +- script/lib/npx.py | 5 ++++- script/nan-spec-runner.js | 3 ++- script/release/uploaders/upload-symbols.py | 4 +++- script/spec-runner.js | 3 ++- script/yarn.js | 6 +++++- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/script/codesign/generate-identity.sh b/script/codesign/generate-identity.sh index 27161ce243..8ed6e33399 100755 --- a/script/codesign/generate-identity.sh +++ b/script/codesign/generate-identity.sh @@ -40,7 +40,7 @@ DevToolsSecurity -enable # security import "$dir"/public.key -k $KEY_CHAIN # Generate Trust Settings -npx ts-node "$(dirname $0)"/gen-trust.ts "$dir"/certificate.cer "$dir"/trust.xml +npm_config_yes=true npx ts-node "$(dirname $0)"/gen-trust.ts "$dir"/certificate.cer "$dir"/trust.xml # Import Trust Settings sudo security trust-settings-import -d "$dir/trust.xml" diff --git a/script/lib/npx.py b/script/lib/npx.py index c4414f94aa..dc156c0eef 100644 --- a/script/lib/npx.py +++ b/script/lib/npx.py @@ -1,10 +1,13 @@ +import os import subprocess import sys def npx(*npx_args): + npx_env = os.environ.copy() + npx_env['npm_config_yes'] = 'true' call_args = [__get_executable_name()] + list(npx_args) - subprocess.check_call(call_args) + subprocess.check_call(call_args, env=npx_env) def __get_executable_name(): diff --git a/script/nan-spec-runner.js b/script/nan-spec-runner.js index 5e67003099..947723e4ca 100644 --- a/script/nan-spec-runner.js +++ b/script/nan-spec-runner.js @@ -22,7 +22,8 @@ async function main () { const env = Object.assign({}, process.env, { npm_config_nodedir: nodeDir, npm_config_msvs_version: '2019', - npm_config_arch: process.env.NPM_CONFIG_ARCH + npm_config_arch: process.env.NPM_CONFIG_ARCH, + npm_config_yes: 'true' }); const { status: buildStatus } = cp.spawnSync(NPX_CMD, ['node-gyp', 'rebuild', '--directory', 'test', '-j', 'max'], { env, diff --git a/script/release/uploaders/upload-symbols.py b/script/release/uploaders/upload-symbols.py index a2d561b56d..bb1cb84102 100755 --- a/script/release/uploaders/upload-symbols.py +++ b/script/release/uploaders/upload-symbols.py @@ -46,9 +46,11 @@ def main(): for symbol_file in files: print("Generating Sentry src bundle for: " + symbol_file) + npx_env = os.environ.copy() + npx_env['npm_config_yes'] = 'true' subprocess.check_output([ NPX_CMD, '@sentry/cli@1.51.1', 'difutil', 'bundle-sources', - symbol_file]) + symbol_file], env=npx_env) files += glob.glob(SYMBOLS_DIR + '/*/*/*.src.zip') diff --git a/script/spec-runner.js b/script/spec-runner.js index 10c478cb6c..ba1f4feaee 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -222,7 +222,8 @@ async function installSpecModules (dir) { const nodeDir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`); const env = Object.assign({}, process.env, { npm_config_nodedir: nodeDir, - npm_config_msvs_version: '2019' + npm_config_msvs_version: '2019', + npm_config_yes: 'true' }); if (fs.existsSync(path.resolve(dir, 'node_modules'))) { await fs.remove(path.resolve(dir, 'node_modules')); diff --git a/script/yarn.js b/script/yarn.js index 7217501d3f..08ff088327 100644 --- a/script/yarn.js +++ b/script/yarn.js @@ -11,7 +11,11 @@ if (process.mainModule === module) { const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'; const child = cp.spawn(NPX_CMD, [`yarn@${YARN_VERSION}`, ...process.argv.slice(2)], { - stdio: 'inherit' + stdio: 'inherit', + env: { + ...process.env, + npm_config_yes: 'true' + } }); child.on('exit', code => process.exit(code));