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
Binary file modified bun.lockb
Binary file not shown.
22 changes: 21 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,23 @@
"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"
},
"lint-staged": {
okineadev marked this conversation as resolved.
Show resolved Hide resolved
"*.{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"
]
},
"publisher": "PKief",
"author": {
Expand Down Expand Up @@ -371,14 +387,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
19 changes: 13 additions & 6 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 @@ -27,10 +27,17 @@ const checkColors = async () => {
...svgFiles.split(' '),
];
const linterProcess = spawn(command);
const { stdout } = await linterProcess;
const linterOutput = await new Response(stdout).text();
const linterResponse = new Response(linterProcess.stdout);

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

// idk how it works but only with this line it correctly exit
// ⚠️⚠️⚠️⚠️⚠️⚠️⚠️ DON'T DELETE ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
await linterProcess.exited;
// ==========================================================
// ==========================================================

process.exit(linterProcess.exitCode);
} else {
console.log('No SVG files to check.');
}
Expand Down
Loading