Created
May 21, 2024 13:38
-
-
Save richard-flosi/824f22833405a2ee140e09798c5c3e81 to your computer and use it in GitHub Desktop.
Pin current devDependencies versions
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
#!/bin/zsh | |
# For each package name | |
for PACKAGE in `npm pkg get devDependencies | jq 'keys[]' | tr -d '"'` | |
do | |
echo "Found ${PACKAGE}" && | |
# Get the current installed version | |
VERSION=`npm ls ${PACKAGE} --depth 0 --json | jq --arg package ${PACKAGE} '.dependencies.[$package].version' | tr -d '"'` && | |
echo "Current version ${VERSION}" && | |
# Update package.json to pin the current version | |
npm pkg set devDependencies.${PACKAGE}=${VERSION} && | |
echo "Pinned ${PACKAGE} to version ${VERSION}" && | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment