Skip to content

Instantly share code, notes, and snippets.

@tcd
Last active June 20, 2022 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcd/db5f796451110050ad23306c393a76dc to your computer and use it in GitHub Desktop.
Save tcd/db5f796451110050ad23306c393a76dc to your computer and use it in GitHub Desktop.
call locally installed npm binary from powershell
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