Last active
March 21, 2025 13:13
-
-
Save yannbertrand/b71b9b9efe75c19abc5f73eb885a395f to your computer and use it in GitHub Desktop.
`nr` bash function to use `node --run` when possible
This file contains hidden or 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
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