Skip to content

Commit d9ff473

Browse files
npm-cli-botruyadorno
authored andcommittedSep 12, 2023
deps: upgrade npm to 9.8.0
PR-URL: #48665 Reviewed-By: Luke Karrys <luke@lukekarrys.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
1 parent 4a6177d commit d9ff473

File tree

135 files changed

+941
-570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+941
-570
lines changed
 

‎deps/npm/bin/npm

+22-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ case `uname` in
1111
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
1212
esac
1313

14+
if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then
15+
IS_WSL="true"
16+
fi
17+
18+
function no_node_dir {
19+
# if this didn't work, then everything else below will fail
20+
echo "Could not determine Node.js install directory" >&2
21+
exit 1
22+
}
23+
1424
NODE_EXE="$basedir/node.exe"
1525
if ! [ -x "$NODE_EXE" ]; then
1626
NODE_EXE="$basedir/node"
@@ -21,13 +31,20 @@ fi
2131

2232
# this path is passed to node.exe, so it needs to match whatever
2333
# kind of paths Node.js thinks it's using, typically win32 paths.
24-
CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)')"
34+
CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)' 2> /dev/null)"
35+
if [ $? -ne 0 ]; then
36+
# this fails under WSL 1 so add an additional message. we also suppress stderr above
37+
# because the actual error raised is not helpful. in WSL 1 node.exe cannot handle
38+
# output redirection properly. See https://github.com/microsoft/WSL/issues/2370
39+
if [ "$IS_WSL" == "true" ]; then
40+
echo "WSL 1 is not supported. Please upgrade to WSL 2 or above." >&2
41+
fi
42+
no_node_dir
43+
fi
2544
NPM_CLI_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-cli.js"
2645
NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
2746
if [ $? -ne 0 ]; then
28-
# if this didn't work, then everything else below will fail
29-
echo "Could not determine Node.js install directory" >&2
30-
exit 1
47+
no_node_dir
3148
fi
3249
NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
3350

@@ -37,7 +54,7 @@ NPM_WSL_PATH="/.."
3754
# WSL can run Windows binaries, so we have to give it the win32 path
3855
# however, WSL bash tests against posix paths, so we need to construct that
3956
# to know if npm is installed globally.
40-
if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then
57+
if [ "$IS_WSL" == "true" ]; then
4158
NPM_WSL_PATH=`wslpath "$NPM_PREFIX_NPM_CLI_JS"`
4259
fi
4360
if [ -f "$NPM_PREFIX_NPM_CLI_JS" ] || [ -f "$NPM_WSL_PATH" ]; then

‎deps/npm/bin/npm.ps1

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env pwsh
2+
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3+
4+
$exe=""
5+
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6+
# Fix case when both the Windows and Linux builds of Node
7+
# are installed in the same directory
8+
$exe=".exe"
9+
}
10+
$ret=0
11+
12+
$nodeexe = "node$exe"
13+
$nodebin = $(Get-Command $nodeexe -ErrorAction SilentlyContinue -ErrorVariable F).Source
14+
if ($nodebin -eq $null) {
15+
Write-Host "$nodeexe not found."
16+
exit 1
17+
}
18+
$nodedir = $(New-Object -ComObject Scripting.FileSystemObject).GetFile("$nodebin").ParentFolder.Path
19+
20+
$npmclijs="$nodedir/node_modules/npm/bin/npm-cli.js"
21+
$npmprefix=(& $nodeexe $npmclijs prefix -g)
22+
if ($LASTEXITCODE -ne 0) {
23+
Write-Host "Could not determine Node.js install directory"
24+
exit 1
25+
}
26+
$npmprefixclijs="$npmprefix/node_modules/npm/bin/npm-cli.js"
27+
28+
# Support pipeline input
29+
if ($MyInvocation.ExpectingInput) {
30+
$input | & $nodeexe $npmprefixclijs $args
31+
} else {
32+
& $nodeexe $npmprefixclijs $args
33+
}
34+
$ret=$LASTEXITCODE
35+
exit $ret

0 commit comments

Comments
 (0)
Please sign in to comment.