Last active
June 20, 2022 15:28
-
-
Save tcd/db5f796451110050ad23306c393a76dc to your computer and use it in GitHub Desktop.
call locally installed npm binary from powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function npm_do { | |
if ($args.Count -lt 1) { | |
throw "At least one argument is required" | |
} | |
$npmBinFolder = $(npm bin) | |
$exePath = -join($npmBinFolder, "\", $args[0], ".ps1") | |
if ($args.Count -eq 1) { | |
. $exePath | |
} else { | |
$exeArgs = $args[1..($args.length - 1)] | |
. $exePath $exeArgs | |
} | |
} | |
Set-Alias npm-do npm_do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment