Skip to content

Instantly share code, notes, and snippets.

@tsukumijima
Created June 8, 2021 17:23
Show Gist options
  • Save tsukumijima/b7fbef4419bde4d6e536187ec4df6fd9 to your computer and use it in GitHub Desktop.
Save tsukumijima/b7fbef4419bde4d6e536187ec4df6fd9 to your computer and use it in GitHub Desktop.
Windows で npm run serve を Ctrl+C で終了すると毎回「バッチ ジョブを終了しますか (Y/N)?」と表示されるのを回避するための PowerShell スクリプト
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/node_modules/npm/bin/npm-cli.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/node_modules/npm/bin/npm-cli.js" $args
$ret=$LASTEXITCODE
}
exit $ret
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/node_modules/npm/bin/npx-cli.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/node_modules/npm/bin/npx-cli.js" $args
$ret=$LASTEXITCODE
}
exit $ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment