Skip to content

Commit 252dd7b

Browse files
committed
updated lefthook config
1 parent 46f2a33 commit 252dd7b

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["ms-azuretools.vscode-docker", "biomejs.biome", "oven.bun-vscode"]
2+
"recommendations": ["biomejs.biome", "oven.bun-vscode"]
33
}

lefthook.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { chmod, exists, mkdir, writeFile } from "node:fs/promises";
2+
import { join } from "node:path";
3+
4+
const HOOKS_DIR = ".git/hooks";
5+
6+
if (!(await exists(".git"))) {
7+
console.error("Error: lefthook.ts script must be run from the root folder of git repo");
8+
process.exit(1);
9+
}
10+
11+
await mkdir(HOOKS_DIR, { recursive: true });
12+
13+
const preCommit = `#!/bin/sh
14+
export PATH="$PWD/node_modules/.bin:$PATH"
15+
lefthook run pre-commit`;
16+
17+
await writeFile(join(HOOKS_DIR, "pre-commit"), preCommit);
18+
19+
await chmod(join(HOOKS_DIR, "pre-commit"), 0o755);
20+
21+
console.log("lefthook hooks installed ✅");
22+
23+
process.exit(0);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"homepage": "https://github.com/DiscIt-API/discit-api#readme",
1717
"scripts": {
1818
"compose": "docker compose -f \"./.discit-dev-container/docker-compose.yml\" up -d --build",
19-
"prepare": "lefthook install",
19+
"prepare": "bun run lefthook.ts",
2020
"lint": "biome lint .",
2121
"format": "biome format --write .",
2222
"check": "biome check .",

0 commit comments

Comments
 (0)