Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(powershell): fallback to script root if globalPrefix does not exist #7450

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/npm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ 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) {
Write-Host "Could not determine Node.js install directory"
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) {
Expand Down
6 changes: 5 additions & 1 deletion bin/npx.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ 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) {
Write-Host "Could not determine Node.js install directory"
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) {
Expand Down
10 changes: 5 additions & 5 deletions tap-snapshots/test/lib/commands/doctor.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}
),
],
}
Expand Down
2 changes: 1 addition & 1 deletion test/lib/commands/doctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading