Skip to content

Commit

Permalink
fix(powershell): use Invoke-Expression to pass args
Browse files Browse the repository at this point in the history
Co-authored-by: noseratio <[email protected]>
  • Loading branch information
lukekarrys and noseratio committed May 1, 2024
1 parent 796971e commit 65cb3de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions bin/npm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ if (Test-Path $NPM_PREFIX_NPM_CLI_JS) {
$NPM_CLI_JS=$NPM_PREFIX_NPM_CLI_JS
}

$NPM_ARGS = $MyInvocation.Line.Substring($MyInvocation.InvocationName.Length).Trim()
$INVOKE_NPM = "$($NODE_EXE -Replace ' ', '` ') $($NPM_CLI_JS -Replace ' ', '` ') $NPM_ARGS".Trim()

# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & $NODE_EXE $NPM_CLI_JS $args
$input | Invoke-Expression $INVOKE_NPM
} else {
& $NODE_EXE $NPM_CLI_JS $args
Invoke-Expression $INVOKE_NPM
}

exit $LASTEXITCODE
7 changes: 5 additions & 2 deletions bin/npx.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ if (Test-Path $NPM_PREFIX_NPX_CLI_JS) {
$NPX_CLI_JS=$NPM_PREFIX_NPX_CLI_JS
}

$NPX_ARGS = $MyInvocation.Line.Substring($MyInvocation.InvocationName.Length).Trim()
$INVOKE_NPX = "$($NODE_EXE -Replace ' ' '` ') $($NPX_CLI_JS -Replace ' ' '` ') $NPX_ARGS".Trim()

# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & $NODE_EXE $NPX_CLI_JS $args
$input | Invoke-Expression $INVOKE_NPX
} else {
& $NODE_EXE $NPX_CLI_JS $args
Invoke-Expression $INVOKE_NPX
}

exit $LASTEXITCODE

0 comments on commit 65cb3de

Please sign in to comment.