Skip to content

Commit 88b3246

Browse files
committed
fixup: add tests and prefix for ps1 scripts
1 parent 512318e commit 88b3246

File tree

5 files changed

+248
-123
lines changed

5 files changed

+248
-123
lines changed

.github/workflows/ci.yml

+33
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,36 @@ jobs:
150150
run: node . test -w smoke-tests --ignore-scripts
151151
- name: Check Git Status
152152
run: node scripts/git-dirty.js
153+
154+
windows-shims:
155+
name: Windows Shims Tests
156+
runs-on: windows-latest
157+
defaults:
158+
run:
159+
shell: cmd
160+
steps:
161+
- name: Checkout
162+
uses: actions/checkout@v3
163+
- name: Setup Git User
164+
run: |
165+
git config --global user.email "npm-cli+bot@github.com"
166+
git config --global user.name "npm CLI robot"
167+
- name: Setup Node
168+
uses: actions/setup-node@v3
169+
with:
170+
node-version: 18.x
171+
cache: npm
172+
- name: Reset Deps
173+
run: node scripts/resetdeps.js
174+
- name: Setup WSL
175+
uses: Vampire/setup-wsl@v2.0.1
176+
- name: Set up Cygwin
177+
uses: egor-tensin/setup-cygwin@v4.0.1
178+
with:
179+
install-dir: C:\Windows\cygwin64
180+
- name: Run Windows Shims Tests
181+
run: node . test --ignore-scripts -- test/bin/windows-shims.js --no-coverage
182+
env:
183+
WINDOWS_SHIMS_TEST: fail
184+
- name: Check Git Status
185+
run: node scripts/git-dirty.js

bin/npm.ps1

+13-4
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,27 @@ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
99
}
1010
$ret=0
1111

12-
$nodebin = $(Get-Command "node$exe" -ErrorAction SilentlyContinue -ErrorVariable F).Source
12+
$nodeexe = "node$exe"
13+
$nodebin = $(Get-Command $nodeexe -ErrorAction SilentlyContinue -ErrorVariable F).Source
1314
if ($nodebin -eq $null) {
14-
Write-Host "node$exe not found."
15+
Write-Host "$nodeexe not found."
1516
exit 1
1617
}
1718
$nodedir = $(New-Object -ComObject Scripting.FileSystemObject).GetFile("$nodebin").ParentFolder.Path
1819

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+
1928
# Support pipeline input
2029
if ($MyInvocation.ExpectingInput) {
21-
$input | & "node$exe" "$nodedir/node_modules/npm/bin/npm-cli.js" $args
30+
$input | & $nodeexe $npmprefixclijs $args
2231
} else {
23-
& "node$exe" "$nodedir/node_modules/npm/bin/npm-cli.js" $args
32+
& $nodeexe $npmprefixclijs $args
2433
}
2534
$ret=$LASTEXITCODE
2635
exit $ret

bin/npx.ps1

+13-4
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,27 @@ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
99
}
1010
$ret=0
1111

12-
$nodebin = $(Get-Command "node$exe" -ErrorAction SilentlyContinue -ErrorVariable F).Source
12+
$nodeexe = "node$exe"
13+
$nodebin = $(Get-Command $nodeexe -ErrorAction SilentlyContinue -ErrorVariable F).Source
1314
if ($nodebin -eq $null) {
14-
Write-Host "node$exe not found."
15+
Write-Host "$nodeexe not found."
1516
exit 1
1617
}
1718
$nodedir = $(New-Object -ComObject Scripting.FileSystemObject).GetFile("$nodebin").ParentFolder.Path
1819

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/npx-cli.js"
27+
1928
# Support pipeline input
2029
if ($MyInvocation.ExpectingInput) {
21-
$input | & "node$exe" "$nodedir/node_modules/npm/bin/npx-cli.js" $args
30+
$input | & $nodeexe $npmprefixclijs $args
2231
} else {
23-
& "node$exe" "$nodedir/node_modules/npm/bin/npx-cli.js" $args
32+
& $nodeexe $npmprefixclijs $args
2433
}
2534
$ret=$LASTEXITCODE
2635
exit $ret

scripts/template-oss/ci.yml

+21
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,24 @@
1111
run: {{rootNpmPath}} test -w smoke-tests --ignore-scripts
1212
- name: Check Git Status
1313
run: node scripts/git-dirty.js
14+
15+
windows-shims:
16+
name: Windows Shims Tests
17+
runs-on: windows-latest
18+
defaults:
19+
run:
20+
shell: cmd
21+
steps:
22+
{{> stepsSetup }}
23+
- name: Setup WSL
24+
uses: Vampire/setup-wsl@v2.0.1
25+
- name: Set up Cygwin
26+
uses: egor-tensin/setup-cygwin@v4.0.1
27+
with:
28+
install-dir: C:\Windows\cygwin64
29+
- name: Run Windows Shims Tests
30+
run: {{rootNpmPath}} test --ignore-scripts -- test/bin/windows-shims.js --no-coverage
31+
env:
32+
WINDOWS_SHIMS_TEST: fail
33+
- name: Check Git Status
34+
run: node scripts/git-dirty.js

0 commit comments

Comments
 (0)