File tree 2 files changed +28
-42
lines changed
2 files changed +28
-42
lines changed Original file line number Diff line number Diff line change 1
1
# !/usr/bin/env pwsh
2
- $basedir = Split-Path $MyInvocation.MyCommand.Definition - Parent
3
2
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"
3
+ $NODE_EXE = " $PSScriptRoot /node.exe"
4
+ if (-not (Test-Path $NODE_EXE )) {
5
+ $NODE_EXE = " $PSScriptRoot /node"
9
6
}
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
7
+ if (-not (Test-Path $NODE_EXE )) {
8
+ $NODE_EXE = " node"
17
9
}
18
- $nodedir = $ (New-Object - ComObject Scripting.FileSystemObject).GetFile(" $nodebin " ).ParentFolder.Path
19
10
20
- $npmprefixjs = " $nodedir /node_modules/npm/bin/npm-prefix.js"
21
- $npmprefix = (& $nodeexe $npmprefixjs )
11
+ $NPM_PREFIX_JS = " $PSScriptRoot /node_modules/npm/bin/npm-prefix.js"
12
+ $NPM_PREFIX = (& $NODE_EXE $NPM_PREFIX_JS )
13
+
22
14
if ($LASTEXITCODE -ne 0 ) {
23
15
Write-Host " Could not determine Node.js install directory"
24
16
exit 1
25
17
}
26
- $npmprefixclijs = " $npmprefix /node_modules/npm/bin/npm-cli.js"
18
+
19
+ $NPM_CLI_JS = " $NPM_PREFIX /node_modules/npm/bin/npm-cli.js"
27
20
28
21
# Support pipeline input
29
22
if ($MyInvocation.ExpectingInput ) {
30
- $input | & $nodeexe $npmprefixclijs $args
23
+ $input | & $NODE_EXE $NPM_CLI_JS $args
31
24
} else {
32
- & $nodeexe $npmprefixclijs $args
25
+ & $NODE_EXE $NPM_CLI_JS $args
33
26
}
34
- $ret = $LASTEXITCODE
35
- exit $ret
27
+
28
+ exit $LASTEXITCODE
Original file line number Diff line number Diff line change 1
1
# !/usr/bin/env pwsh
2
- $basedir = Split-Path $MyInvocation.MyCommand.Definition - Parent
3
2
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"
3
+ $NODE_EXE = " $PSScriptRoot /node.exe"
4
+ if (-not (Test-Path $NODE_EXE )) {
5
+ $NODE_EXE = " $PSScriptRoot /node"
9
6
}
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
7
+ if (-not (Test-Path $NODE_EXE )) {
8
+ $NODE_EXE = " node"
17
9
}
18
- $nodedir = $ (New-Object - ComObject Scripting.FileSystemObject).GetFile(" $nodebin " ).ParentFolder.Path
19
10
20
- $npmprefixjs = " $nodedir /node_modules/npm/bin/npm-prefix.js"
21
- $npmprefix = (& $nodeexe $npmprefixjs )
11
+ $NPM_PREFIX_JS = " $PSScriptRoot /node_modules/npm/bin/npm-prefix.js"
12
+ $NPM_PREFIX = (& $NODE_EXE $NPM_PREFIX_JS )
13
+
22
14
if ($LASTEXITCODE -ne 0 ) {
23
15
Write-Host " Could not determine Node.js install directory"
24
16
exit 1
25
17
}
26
- $npmprefixclijs = " $npmprefix /node_modules/npm/bin/npx-cli.js"
18
+
19
+ $NPX_CLI_JS = " $NPM_PREFIX /node_modules/npm/bin/npx-cli.js"
27
20
28
21
# Support pipeline input
29
22
if ($MyInvocation.ExpectingInput ) {
30
- $input | & $nodeexe $npmprefixclijs $args
23
+ $input | & $NODE_EXE $NPX_CLI_JS $args
31
24
} else {
32
- & $nodeexe $npmprefixclijs $args
25
+ & $NODE_EXE $NPX_CLI_JS $args
33
26
}
34
- $ret = $LASTEXITCODE
35
- exit $ret
27
+
28
+ exit $LASTEXITCODE
You can’t perform that action at this time.
0 commit comments