Skip to content

Commit

Permalink
chore: add package-lock checking
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaPeach committed Feb 28, 2024
1 parent c262e85 commit ed94e5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion husky.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
'commit-msg': isWindows
? ''
: `[[ -n $HUSKY_BYPASS ]] || commitlint -e $HUSKY_GIT_PARAMS --config ${commitLintConfig}`,
'pre-commit': 'node ./scripts/dev/generate-all.js && npm run lint-staged && git add -A',
'pre-commit':
'node ./scripts/dev/check-lock.js && node ./scripts/dev/generate-all.js && npm run lint-staged && git add -A',
},
};
10 changes: 10 additions & 0 deletions scripts/dev/check-lock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require('fs');
const path = require('path');

const lockFile = path.resolve(__dirname, '../../package-lock.json');
const lockStr = fs.readFileSync(lockFile, 'utf8');
const wrongRegistryMatch = lockStr.match(/"resolved": "https?:\/\/((?!registry\.npmjs\.org).*?)\//);
if (wrongRegistryMatch) {
console.error(`\nError: Wrong package resolve path! (Found wrong path: ${wrongRegistryMatch[1]}) Please check your npm registry and install again.\n`);
throw new Error();
}

0 comments on commit ed94e5d

Please sign in to comment.