Skip to content

Commit

Permalink
chore: updated git hooks scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
gperdomor committed Oct 14, 2023
1 parent b699d50 commit a946253
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
npx --no -- commitlint --edit "$1"
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx validate-branch-name -r "^(master|main|develop){1}$|^(feature|fix|hotfix|release|renovate)/.+$"
npx --no -- validate-branch-name -r "^(master|main|develop){1}$|^(feature|fix|hotfix|release|renovate)/.+$"
npx --no -- lint-staged
npm run check-lock-files
npx --no-install lint-staged --concurrent false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"scripts": {
"commit": "cz",
"check-lock-files": "node ./tools/scripts/check-lock-files.js",
"check-lock-files": "node ./tools/scripts/check-lock-files.mjs",
"prepare": "is-ci || husky install"
},
"private": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { readFileSync, existsSync } = require('node:fs');
import { existsSync, readFileSync } from 'node:fs';

function checkLockFiles() {
async function checkLockFiles() {
const errors = [];
if (existsSync('yarn.lock')) {
errors.push('Invalid occurence of "yarn.lock" file. Please remove it and use only "package-lock.json"');
Expand All @@ -16,8 +16,7 @@ function checkLockFiles() {
);
}

// eslint-disable-next-line global-require
const packageJson = require('../../package-lock.json');
const { default: packageJson } = await import('../../package-lock.json', { assert: { type: 'json' } });

if (packageJson.lockfileVersion !== 3) {
errors.push(
Expand All @@ -30,11 +29,13 @@ function checkLockFiles() {
return errors;
}

const invalid = checkLockFiles();
console.log('🔒🔒🔒 Validating lock files 🔒🔒🔒\n');
const invalid = await checkLockFiles();

if (invalid.length > 0) {
invalid.forEach((e) => console.log(e));
process.exit(1);
} else {
console.log('Lock file is valid 👍');
process.exit(0);
}

0 comments on commit a946253

Please sign in to comment.