Skip to content

Commit

Permalink
fixup: add tests and prefix for ps1 scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Jun 23, 2023
1 parent aa4bf21 commit 26a0b81
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 97 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,36 @@ jobs:
run: node . test -w smoke-tests --ignore-scripts
- name: Check Git Status
run: node scripts/git-dirty.js

windows-shims:
name: Windows Shims Tests
runs-on: windows-latest
defaults:
run:
shell: cmd
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: npm
- name: Reset Deps
run: node . run resetdeps
- name: Setup WSL
uses: Vampire/setup-wsl@v2.0.1
- name: Set up Cygwin
uses: egor-tensin/setup-cygwin@v4.0.1
with:
install-dir: C:\Windows\cygwin64
- name: Run Windows Shims Tests
run: node . test --ignore-scripts -- test/bin/windows-shims.js --no-coverage
env:
WINDOWS_SHIMS_TEST: fail
- name: Check Git Status
run: node scripts/git-dirty.js
17 changes: 13 additions & 4 deletions bin/npm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,27 @@ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
}
$ret=0

$nodebin = $(Get-Command "node$exe" -ErrorAction SilentlyContinue -ErrorVariable F).Source
$nodeexe = "node$exe"
$nodebin = $(Get-Command $nodeexe -ErrorAction SilentlyContinue -ErrorVariable F).Source
if ($nodebin -eq $null) {
Write-Host "node$exe not found."
Write-Host "$nodeexe not found."
exit 1
}
$nodedir = $(New-Object -ComObject Scripting.FileSystemObject).GetFile("$nodebin").ParentFolder.Path

$npmclijs="$nodedir/node_modules/npm/bin/npm-cli.js"
$npmprefix=(& $nodeexe $npmclijs prefix -g)
if ($LASTEXITCODE -ne 0) {
Write-Host "Could not determine Node.js install directory"
exit 1
}
$npmprefixclijs="$npmprefix/node_modules/npm/bin/npm-cli.js"

# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$nodedir/node_modules/npm/bin/npm-cli.js" $args
$input | & $nodeexe $npmprefixclijs $args
} else {
& "node$exe" "$nodedir/node_modules/npm/bin/npm-cli.js" $args
& $nodeexe $npmprefixclijs $args
}
$ret=$LASTEXITCODE
exit $ret
17 changes: 13 additions & 4 deletions bin/npx.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,27 @@ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
}
$ret=0

$nodebin = $(Get-Command "node$exe" -ErrorAction SilentlyContinue -ErrorVariable F).Source
$nodeexe = "node$exe"
$nodebin = $(Get-Command $nodeexe -ErrorAction SilentlyContinue -ErrorVariable F).Source
if ($nodebin -eq $null) {
Write-Host "node$exe not found."
Write-Host "$nodeexe not found."
exit 1
}
$nodedir = $(New-Object -ComObject Scripting.FileSystemObject).GetFile("$nodebin").ParentFolder.Path

$npmclijs="$nodedir/node_modules/npm/bin/npm-cli.js"
$npmprefix=(& $nodeexe $npmclijs prefix -g)
if ($LASTEXITCODE -ne 0) {
Write-Host "Could not determine Node.js install directory"
exit 1
}
$npmprefixclijs="$npmprefix/node_modules/npm/bin/npx-cli.js"

# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$nodedir/node_modules/npm/bin/npx-cli.js" $args
$input | & $nodeexe $npmprefixclijs $args
} else {
& "node$exe" "$nodedir/node_modules/npm/bin/npx-cli.js" $args
& $nodeexe $npmprefixclijs $args
}
$ret=$LASTEXITCODE
exit $ret
21 changes: 21 additions & 0 deletions scripts/template-oss/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,24 @@
run: {{rootNpmPath}} test -w smoke-tests --ignore-scripts
- name: Check Git Status
run: node scripts/git-dirty.js

windows-shims:
name: Windows Shims Tests
runs-on: windows-latest
defaults:
run:
shell: cmd
steps:
{{> stepsSetup }}
- name: Setup WSL
uses: Vampire/setup-wsl@v2.0.1
- name: Set up Cygwin
uses: egor-tensin/setup-cygwin@v4.0.1
with:
install-dir: C:\cygwin64
- name: Run Windows Shims Tests
run: {{rootNpmPath}} test --ignore-scripts -- test/bin/windows-shims.js --no-coverage
env:
WINDOWS_SHIMS_TEST: true
- name: Check Git Status
run: node scripts/git-dirty.js
Loading

0 comments on commit 26a0b81

Please sign in to comment.