Skip to content

Commit 2558283

Browse files
authoredApr 30, 2024··
fix(powershell): fallback to script root if globalPrefix does not exist (#7450)
This matches the behavior of the bash and cmd scripts.
1 parent bc4c342 commit 2558283

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed
 

‎bin/npm.ps1

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ if (-not (Test-Path $NODE_EXE)) {
99
}
1010

1111
$NPM_PREFIX_JS="$PSScriptRoot/node_modules/npm/bin/npm-prefix.js"
12+
$NPM_CLI_JS="$PSScriptRoot/node_modules/npm/bin/npm-cli.js"
1213
$NPM_PREFIX=(& $NODE_EXE $NPM_PREFIX_JS)
1314

1415
if ($LASTEXITCODE -ne 0) {
1516
Write-Host "Could not determine Node.js install directory"
1617
exit 1
1718
}
1819

19-
$NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
20+
$NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
21+
if (Test-Path $NPM_PREFIX_NPM_CLI_JS) {
22+
$NPM_CLI_JS=$NPM_PREFIX_NPM_CLI_JS
23+
}
2024

2125
# Support pipeline input
2226
if ($MyInvocation.ExpectingInput) {

‎bin/npx.ps1

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ if (-not (Test-Path $NODE_EXE)) {
99
}
1010

1111
$NPM_PREFIX_JS="$PSScriptRoot/node_modules/npm/bin/npm-prefix.js"
12+
$NPX_CLI_JS="$PSScriptRoot/node_modules/npm/bin/npx-cli.js"
1213
$NPM_PREFIX=(& $NODE_EXE $NPM_PREFIX_JS)
1314

1415
if ($LASTEXITCODE -ne 0) {
1516
Write-Host "Could not determine Node.js install directory"
1617
exit 1
1718
}
1819

19-
$NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"
20+
$NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"
21+
if (Test-Path $NPM_PREFIX_NPX_CLI_JS) {
22+
$NPX_CLI_JS=$NPM_PREFIX_NPX_CLI_JS
23+
}
2024

2125
# Support pipeline input
2226
if ($MyInvocation.ExpectingInput) {

‎tap-snapshots/test/lib/commands/doctor.js.test.cjs

+5-5
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,11 @@ Object {
731731
"warn": Array [
732732
String(
733733
doctor getGitPath Error: test error
734-
doctor at which {STACK}
735-
doctor at Doctor.getGitPath {STACK}
736-
doctor at Doctor.exec {STACK}
737-
doctor at processTicksAndRejections {STACK}
738-
doctor at MockNpm.exec {STACK}
734+
doctor at {STACK}
735+
doctor at {STACK}
736+
doctor at {STACK}
737+
doctor at {STACK}
738+
doctor at {STACK}
739739
),
740740
],
741741
}

‎test/lib/commands/doctor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const cleanCacheSha = (str) =>
1111
str.replace(/content-v2\/sha512\/[^"]+/g, 'content-v2/sha512/{sha}')
1212

1313
t.cleanSnapshot = p => cleanCacheSha(cleanDate(cleanCwd(p)))
14-
.replace(/\s\((\{CWD\}|node:).*\d+:\d+\)$/gm, ' {STACK}')
14+
.replace(/(doctor\s+at\s).*$/gm, '$1{STACK}')
1515

1616
const npmManifest = (version) => {
1717
return {

0 commit comments

Comments
 (0)