Skip to content

Commit 65cb3de

Browse files
lukekarrysnoseratio
andcommitted
fix(powershell): use Invoke-Expression to pass args
Co-authored-by: noseratio <[email protected]>
1 parent 796971e commit 65cb3de

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

bin/npm.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ if (Test-Path $NPM_PREFIX_NPM_CLI_JS) {
2222
$NPM_CLI_JS=$NPM_PREFIX_NPM_CLI_JS
2323
}
2424

25+
$NPM_ARGS = $MyInvocation.Line.Substring($MyInvocation.InvocationName.Length).Trim()
26+
$INVOKE_NPM = "$($NODE_EXE -Replace ' ', '` ') $($NPM_CLI_JS -Replace ' ', '` ') $NPM_ARGS".Trim()
27+
2528
# Support pipeline input
2629
if ($MyInvocation.ExpectingInput) {
27-
$input | & $NODE_EXE $NPM_CLI_JS $args
30+
$input | Invoke-Expression $INVOKE_NPM
2831
} else {
29-
& $NODE_EXE $NPM_CLI_JS $args
32+
Invoke-Expression $INVOKE_NPM
3033
}
3134

3235
exit $LASTEXITCODE

bin/npx.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ if (Test-Path $NPM_PREFIX_NPX_CLI_JS) {
2222
$NPX_CLI_JS=$NPM_PREFIX_NPX_CLI_JS
2323
}
2424

25+
$NPX_ARGS = $MyInvocation.Line.Substring($MyInvocation.InvocationName.Length).Trim()
26+
$INVOKE_NPX = "$($NODE_EXE -Replace ' ' '` ') $($NPX_CLI_JS -Replace ' ' '` ') $NPX_ARGS".Trim()
27+
2528
# Support pipeline input
2629
if ($MyInvocation.ExpectingInput) {
27-
$input | & $NODE_EXE $NPX_CLI_JS $args
30+
$input | Invoke-Expression $INVOKE_NPX
2831
} else {
29-
& $NODE_EXE $NPX_CLI_JS $args
32+
Invoke-Expression $INVOKE_NPX
3033
}
3134

3235
exit $LASTEXITCODE

0 commit comments

Comments
 (0)