Last active
May 3, 2024 07:03
-
-
Save adriangalilea/7f5f4602b80099b86b0d9b06a9dd3373 to your computer and use it in GitHub Desktop.
useful package.json scripts and bash function to use it from cli
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
function npm-scripts() { | |
# Define the Gist URL directly within the function | |
local gist_url="https://gist.githubusercontent.com/adriangalilea/7f5f4602b80099b86b0d9b06a9dd3373/raw/808d9b8e81b6216f7eab85fe13e33edce0a286d5/scripts.json" | |
# Check if package.json exists in the current directory | |
if [ -f "package.json" ]; then | |
# Fetch JSON from Gist and update package.json | |
curl -s "$gist_url" | jq --slurpfile newScripts /dev/stdin '.scripts |= . + $newScripts[0]' package.json > package.json.tmp && mv package.json.tmp package.json | |
echo "Scripts updated in package.json" | |
else | |
echo "No package.json found in the current directory." | |
fi | |
} |
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
{ | |
"format": "prettier --write .", | |
"validate": "npm run lint && npm run lint:js && npm run format", | |
"purge": "rm -rf node_modules package-lock.json && npm cache clean --force", | |
"purge:all": "npm run purge && rm -rf .next build", | |
"reinstall": "npm run purge && npm install", | |
"reinstall:all": "npm run purge:all && npm install" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment