diff --git a/bin/npm.ps1 b/bin/npm.ps1 index 04a1fd478ef9d..9b3756646fcfb 100644 --- a/bin/npm.ps1 +++ b/bin/npm.ps1 @@ -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 diff --git a/bin/npx.ps1 b/bin/npx.ps1 index 28dae51b22ca9..066bc74020e27 100644 --- a/bin/npx.ps1 +++ b/bin/npx.ps1 @@ -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