Skip to content

Commit 5ad49a0

Browse files
authored
build: Add husky pre-commit hook (#8)
* build: Add husky pre-commit hook * build: Add code formatting with Prettier and update pre-commit hook Signed-off-by: Eden Reich <[email protected]> * build: Add build step to pre-commit hook Signed-off-by: Eden Reich <[email protected]> --------- Signed-off-by: Eden Reich <[email protected]>
1 parent 200eb12 commit 5ad49a0

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

.husky/pre-commit

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
# Format code
5+
npm run format
6+
# Lint code
7+
npm run lint
8+
# Run build
9+
npm run build
10+
# Run tests
11+
npm test

package-lock.json

+23-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"build": "tsc",
5050
"test": "jest",
5151
"lint": "eslint src/**/*.ts",
52-
"prepare": "npm run build"
52+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
53+
"prepare": "husky"
5354
},
5455
"devDependencies": {
5556
"@eslint/js": "^9.18.0",
@@ -59,7 +60,9 @@
5960
"@typescript-eslint/parser": "^8.21.0",
6061
"eslint": "^9.18.0",
6162
"eslint-plugin-prettier": "^5.2.3",
63+
"husky": "^9.1.7",
6264
"jest": "^29.7.0",
65+
"prettier": "^3.5.3",
6366
"ts-jest": "^29.2.5",
6467
"typescript": "^5.7.3"
6568
},

tests/client.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ describe('InferenceGatewayClient', () => {
387387
id: 'call_123',
388388
type: 'function',
389389
function: {
390-
name: 'get_weather',
391-
arguments: '{"location":"San Francisco, CA"}'
392-
}
390+
name: 'get_weather',
391+
arguments: '{"location":"San Francisco, CA"}',
392+
},
393393
});
394394
expect(callbacks.onFinish).toHaveBeenCalledTimes(1);
395395
});

0 commit comments

Comments
 (0)