Skip to content

Instantly share code, notes, and snippets.

@yannbertrand
Last active March 21, 2025 13:13
Show Gist options
  • Save yannbertrand/b71b9b9efe75c19abc5f73eb885a395f to your computer and use it in GitHub Desktop.
Save yannbertrand/b71b9b9efe75c19abc5f73eb885a395f to your computer and use it in GitHub Desktop.
`nr` bash function to use `node --run` when possible
nr() {
node_version=$(node -v)
major=$(echo $node_version | cut -c 2-3)
if [[ $(($major)) -gt 21 ]]
then
echo "node $node_version, using node --run $@ ⚡\n"
node --run $@
else
echo "node $node_version, using npm run $@\n"
npm run $@
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment