From a6424de0f3fdc814773863d8ca308e7c8b131a6f Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Tue, 30 Apr 2024 09:17:57 -0700 Subject: [PATCH 1/2] fix(powershell): fallback to script root if globalPrefix does not exist --- bin/npm.ps1 | 6 +++++- bin/npx.ps1 | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/npm.ps1 b/bin/npm.ps1 index 797004fd3dc42..04a1fd478ef9d 100644 --- a/bin/npm.ps1 +++ b/bin/npm.ps1 @@ -9,6 +9,7 @@ if (-not (Test-Path $NODE_EXE)) { } $NPM_PREFIX_JS="$PSScriptRoot/node_modules/npm/bin/npm-prefix.js" +$NPM_CLI_JS="$PSScriptRoot/node_modules/npm/bin/npm-cli.js" $NPM_PREFIX=(& $NODE_EXE $NPM_PREFIX_JS) if ($LASTEXITCODE -ne 0) { @@ -16,7 +17,10 @@ if ($LASTEXITCODE -ne 0) { exit 1 } -$NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js" +$NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js" +if (Test-Path $NPM_PREFIX_NPM_CLI_JS) { + $NPM_CLI_JS=$NPM_PREFIX_NPM_CLI_JS +} # Support pipeline input if ($MyInvocation.ExpectingInput) { diff --git a/bin/npx.ps1 b/bin/npx.ps1 index 01b851a82e8bb..28dae51b22ca9 100644 --- a/bin/npx.ps1 +++ b/bin/npx.ps1 @@ -9,6 +9,7 @@ if (-not (Test-Path $NODE_EXE)) { } $NPM_PREFIX_JS="$PSScriptRoot/node_modules/npm/bin/npm-prefix.js" +$NPX_CLI_JS="$PSScriptRoot/node_modules/npm/bin/npx-cli.js" $NPM_PREFIX=(& $NODE_EXE $NPM_PREFIX_JS) if ($LASTEXITCODE -ne 0) { @@ -16,7 +17,10 @@ if ($LASTEXITCODE -ne 0) { exit 1 } -$NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js" +$NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js" +if (Test-Path $NPM_PREFIX_NPX_CLI_JS) { + $NPX_CLI_JS=$NPM_PREFIX_NPX_CLI_JS +} # Support pipeline input if ($MyInvocation.ExpectingInput) { From c6ef09a15a682b394e24b6d32065f470aede779a Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Tue, 30 Apr 2024 09:24:54 -0700 Subject: [PATCH 2/2] chore: remove fn names in stack trace from doctor snapshot --- tap-snapshots/test/lib/commands/doctor.js.test.cjs | 10 +++++----- test/lib/commands/doctor.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tap-snapshots/test/lib/commands/doctor.js.test.cjs b/tap-snapshots/test/lib/commands/doctor.js.test.cjs index 5c5b122477d81..0481c6d86823e 100644 --- a/tap-snapshots/test/lib/commands/doctor.js.test.cjs +++ b/tap-snapshots/test/lib/commands/doctor.js.test.cjs @@ -731,11 +731,11 @@ Object { "warn": Array [ String( doctor getGitPath Error: test error - doctor at which {STACK} - doctor at Doctor.getGitPath {STACK} - doctor at Doctor.exec {STACK} - doctor at processTicksAndRejections {STACK} - doctor at MockNpm.exec {STACK} + doctor at {STACK} + doctor at {STACK} + doctor at {STACK} + doctor at {STACK} + doctor at {STACK} ), ], } diff --git a/test/lib/commands/doctor.js b/test/lib/commands/doctor.js index cbe74aba53ff7..bf4ea46a918a1 100644 --- a/test/lib/commands/doctor.js +++ b/test/lib/commands/doctor.js @@ -11,7 +11,7 @@ const cleanCacheSha = (str) => str.replace(/content-v2\/sha512\/[^"]+/g, 'content-v2/sha512/{sha}') t.cleanSnapshot = p => cleanCacheSha(cleanDate(cleanCwd(p))) - .replace(/\s\((\{CWD\}|node:).*\d+:\d+\)$/gm, ' {STACK}') + .replace(/(doctor\s+at\s).*$/gm, '$1{STACK}') const npmManifest = (version) => { return {