Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add package-lock checking #240

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
Loading