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

feat: 🧑‍💻 add husky pre-commit hooks #2720

Merged
merged 12 commits into from
Dec 11, 2024
Merged
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bunx lint-staged
6 changes: 6 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": ["bun run lint"],
"*.{js,ts}": ["bun run test"],
"icons/*.svg": ["bun run check", "bun run check-colors"],
"*.md": ["bun run markdownlint"]
}
Binary file modified bun.lockb
Binary file not shown.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"vscode:prepublish": "bun run lint && bun run build",
"verify": "sheriff verify",
"prepublishOnly": "bun ./src/scripts/module/prepare.ts",
"postpublish": "git checkout package.json && git checkout README.md"
"postpublish": "git checkout package.json && git checkout README.md",
"prepare": "husky"
},
"publisher": "PKief",
"author": {
Expand Down Expand Up @@ -371,14 +372,18 @@
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@commitlint/config-conventional": "^19.5.0",
"@softarc/sheriff-core": "^0.18.0",
"@types/chroma-js": "^2.4.4",
"@types/puppeteer": "^7.0.0",
"@types/vscode": "~1.55.0",
"axios": "^1.7.2",
"bun-types": "^1.1.20",
"changelogen": "^0.5.7",
"commitlint": "^19.5.0",
"esbuild": "^0.24.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"markdownlint-cli": "^0.43.0",
"puppeteer": "^23.0.0",
"rimraf": "^6.0.1",
Expand Down
12 changes: 9 additions & 3 deletions src/scripts/svg/checkSvgColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const checkColors = async () => {
// Execute Git command to get list of modified SVG files
const gitProcess = spawn([
'git',
'ls-files',
'-mo',
'--exclude-standard',
'diff',
'--cached',
'--name-only',
'--',
'*.svg',
]);
Expand All @@ -31,6 +31,12 @@ const checkColors = async () => {
const linterOutput = await new Response(stdout).text();

console.log('Colors check output:\n\n', linterOutput);

// Wait for the sub process to finish with an exit code
await linterProcess.exited;

// Exit script with exit code (0 == no errors, 1 == errors)
process.exit(linterProcess.exitCode);
} else {
console.log('No SVG files to check.');
}
Expand Down
Loading