Created
May 21, 2024 13:36
-
-
Save richard-flosi/f0886b2a698c1620bee84615abf1597e to your computer and use it in GitHub Desktop.
Pin current dependencies 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 dependencies | 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 dependencies.${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