diff --git a/bin/npm.ps1 b/bin/npm.ps1 index 4e4aaa78c87ca..e18a672625354 100644 --- a/bin/npm.ps1 +++ b/bin/npm.ps1 @@ -26,7 +26,7 @@ if (Test-Path $NPM_PREFIX_NPM_CLI_JS) { if ($MyInvocation.ExpectingInput) { # takes pipeline input $input | & $NODE_EXE $NPM_CLI_JS $args -} elseif (-not $MyInvocation.Line) { # used "-File" argument +} elseif (-not $MyInvocation.Line -or $MyInvocation.InvocationName -in '&', '.') { # used "-File" argument & $NODE_EXE $NPM_CLI_JS $args } else { # used "-Command" argument if (($MyInvocation | Get-Member -Name 'Statement') -and $MyInvocation.Statement) { diff --git a/bin/npx.ps1 b/bin/npx.ps1 index 05c76825e0d01..60ba47ba39641 100644 --- a/bin/npx.ps1 +++ b/bin/npx.ps1 @@ -26,7 +26,7 @@ if (Test-Path $NPM_PREFIX_NPX_CLI_JS) { if ($MyInvocation.ExpectingInput) { # takes pipeline input $input | & $NODE_EXE $NPX_CLI_JS $args -} elseif (-not $MyInvocation.Line) { # used "-File" argument +} elseif (-not $MyInvocation.Line -or $MyInvocation.InvocationName -in '&', '.') { # used "-File" argument & $NODE_EXE $NPX_CLI_JS $args } else { # used "-Command" argument if (($MyInvocation | Get-Member -Name 'Statement') -and $MyInvocation.Statement) {