Browse Source

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
Samuel Attard 4 years ago
parent
commit
b894151745

+ 1 - 1
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"

+ 4 - 1
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():

+ 2 - 1
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,

+ 3 - 1
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/[email protected]', 'difutil', 'bundle-sources',
-      symbol_file])
+      symbol_file], env=npx_env)
 
   files += glob.glob(SYMBOLS_DIR + '/*/*/*.src.zip')
 

+ 2 - 1
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'));

+ 5 - 1
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));