Skip to content

Commit b9381d7

Browse files
committed
chore(git): add husky pre-push format hook
- add husky devDependency and prepare script - configure pre-push hook to run pnpm format - harden sync-grammars and extend search hints test timeout to avoid flakiness
1 parent 034536d commit b9381d7

6 files changed

Lines changed: 37 additions & 3 deletions

File tree

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm test

.husky/pre-push

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
echo "Running pnpm format before push..."
5+
pnpm format
6+

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@
120120
"format:check": "prettier --check \"src/**/*.ts\"",
121121
"type-check": "tsc --noEmit",
122122
"mcp:inspect": "npx -y @modelcontextprotocol/inspector node dist/index.js .",
123-
"eval": "pnpm run build && node scripts/run-eval.mjs"
123+
"eval": "pnpm run build && node scripts/run-eval.mjs",
124+
"prepare": "husky"
124125
},
125126
"dependencies": {
126127
"@huggingface/transformers": "^3.8.1",
@@ -148,6 +149,7 @@
148149
"eslint-config-prettier": "^10.1.8",
149150
"eslint-plugin-import": "^2.32.0",
150151
"globals": "^17.0.0",
152+
"husky": "^9.1.7",
151153
"prettier": "^3.7.4",
152154
"tree-sitter-wasms": "^0.1.13",
153155
"tsx": "^4.21.0",

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/sync-grammars.mjs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,22 @@ for (const wasm of CURATED_WASMS) {
4545
// Atomic copy: write to temp name then rename to avoid partial files
4646
const tmp = dest + '.tmp-' + randomBytes(4).toString('hex');
4747
fs.copyFileSync(src, tmp);
48-
fs.renameSync(tmp, dest);
48+
49+
try {
50+
fs.renameSync(tmp, dest);
51+
} catch (error) {
52+
try {
53+
fs.rmSync(tmp, { force: true });
54+
} catch {
55+
// Best-effort cleanup; ignore if removal fails
56+
}
57+
58+
if (error && typeof error === 'object' && 'code' in error && (error.code === 'EPERM' || error.code === 'EBUSY')) {
59+
console.warn(`sync-grammars: skipped updating ${wasm} due to file lock (${error.code})`);
60+
} else {
61+
throw error;
62+
}
63+
}
4964
copied++;
5065
}
5166

tests/search-hints.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('Search Hints', () => {
9696
expect(typeof caller).toBe('string');
9797
});
9898
}
99-
});
99+
}, 60000);
100100

101101
it('hints are capped at 3 items per category', async () => {
102102
if (!tempRoot) throw new Error('tempRoot not initialized');

0 commit comments

Comments
 (0)