Last active
June 2, 2023 09:39
-
-
Save Ajnasz/22838f49728b51979ac4a03494ece36a to your computer and use it in GitHub Desktop.
pinpoint package versions in package.json, getting versions from package-lock.json
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
jq < package.json '.dependencies | to_entries[]|select(.value|startswith("^"))|.key' | \ | |
xargs -I {} jq --arg v {} '.dependencies[$v]|{($v): .version}' package-lock.json | \ | |
jq 'to_entries[]|.key+" "+.value' | \ | |
xargs -P 1 -I {} sh -c 'key=$(echo {} | cut -f 1 -d " ");value=$(echo {} | cut -f 2 -d " ");jq --arg k $key --arg v $value ".dependencies[\$k]=\$v" package.json> package.tmp.json && mv package.tmp.json package.json' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment