Add dedupe commands to commit hook

Change-type: patch
Signed-off-by: Vipul Gupta (@vipulgupta2048) <vipulgupta2048@gmail.com>
This commit is contained in:
Vipul Gupta (@vipulgupta2048) 2023-11-08 22:12:02 +05:30
parent 47a1a9c6af
commit 180c59913b
No known key found for this signature in database
GPG Key ID: D76FE376041D2649
3 changed files with 19 additions and 26 deletions

View File

@ -2,19 +2,12 @@
set -e
cp npm-shrinkwrap.json npm-shrinkwrap.json.old
npm i
npm dedupe
npm i
if ! diff -q npm-shrinkwrap.json npm-shrinkwrap.json.old > /dev/null; then
if npm dedupe --dry-run | grep "remove"; then
cp npm-shrinkwrap.json npm-shrinkwrap.json.old
npm dedupe
diff npm-shrinkwrap.json.old npm-shrinkwrap.json;
rm npm-shrinkwrap.json.old
echo "** npm-shrinkwrap.json was not deduplicated or not fully committed - FAIL **";
echo "** This can usually be fixed with: **";
echo "** git checkout master -- npm-shrinkwrap.json **";
echo "** rm -rf node_modules **";
echo "** npm install && npm dedupe && npm install **";
echo "** Please run 'npm ci', followed by 'npm dedupe' **";
exit 1;
fi
rm npm-shrinkwrap.json.old
fi

24
npm-shrinkwrap.json generated
View File

@ -3285,9 +3285,9 @@
}
},
"node_modules/@types/js-yaml": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.8.tgz",
"integrity": "sha512-m6jnPk1VhlYRiLFm3f8X9Uep761f+CK8mHyS65LutH2OhmBF0BeMEjHgg05usH8PLZMWWc/BUR9RPmkvpWnyRA==",
"version": "4.0.9",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz",
"integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==",
"dev": true
},
"node_modules/@types/json-schema": {
@ -3408,9 +3408,9 @@
}
},
"node_modules/@types/node": {
"version": "18.18.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.8.tgz",
"integrity": "sha512-OLGBaaK5V3VRBS1bAkMVP2/W9B+H8meUfl866OrMNQqt7wDgdpWPp5o6gmIc9pB+lIQHSq4ZL8ypeH1vPxcPaQ==",
"version": "18.18.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.9.tgz",
"integrity": "sha512-0f5klcuImLnG4Qreu9hPj/rEfFq6YRc5n2mAjSsH+ec/mJL+3voBH0+8T7o8RpFjH7ovc+TRsL/c7OYIQsPTfQ==",
"dependencies": {
"undici-types": "~5.26.4"
}
@ -26710,9 +26710,9 @@
}
},
"@types/js-yaml": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.8.tgz",
"integrity": "sha512-m6jnPk1VhlYRiLFm3f8X9Uep761f+CK8mHyS65LutH2OhmBF0BeMEjHgg05usH8PLZMWWc/BUR9RPmkvpWnyRA==",
"version": "4.0.9",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz",
"integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==",
"dev": true
},
"@types/json-schema": {
@ -26832,9 +26832,9 @@
}
},
"@types/node": {
"version": "18.18.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.8.tgz",
"integrity": "sha512-OLGBaaK5V3VRBS1bAkMVP2/W9B+H8meUfl866OrMNQqt7wDgdpWPp5o6gmIc9pB+lIQHSq4ZL8ypeH1vPxcPaQ==",
"version": "18.18.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.9.tgz",
"integrity": "sha512-0f5klcuImLnG4Qreu9hPj/rEfFq6YRc5n2mAjSsH+ec/mJL+3voBH0+8T7o8RpFjH7ovc+TRsL/c7OYIQsPTfQ==",
"requires": {
"undici-types": "~5.26.4"
}

View File

@ -92,7 +92,7 @@
},
"husky": {
"hooks": {
"pre-commit": "node automation/check-npm-version.js && ts-node automation/check-doc.ts"
"pre-commit": "node automation/check-npm-version.js && ts-node automation/check-doc.ts && npm run test:shrinkwrap"
}
},
"oclif": {