Skip to content

Commit c85993a

Browse files
committed
Introduce husky to pre-build the backend
1 parent f584723 commit c85993a

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

backend/.husky/pre-commit

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
npm run format
2+
npm run lint
3+
4+
# Run production consolidate script before commit
5+
./scripts/consolidateForProd.sh
6+
7+
npm run copy:data
8+
npm run build

backend/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"scripts": {
77
"dev": "npm-run-all snippets:consolidate dev:server",
88
"dev:server": "tsx index.ts",
9-
"build": "npm-run-all --parallel snippets:consolidate build:server",
10-
"build:server": "tsup index.ts --out-dir dist --format esm",
9+
"build": "tsup index.ts --out-dir dist --format esm",
1110
"start": "node dist/index.js",
1211
"lint": "eslint .",
1312
"format": "prettier --write .",
1413
"format:check": "prettier --check .",
14+
"copy:data": "tsx ./scripts/copyStatic.ts",
1515
"snippets:check": "tsx ./scripts/checkSnippetFormatting.ts",
16-
"snippets:consolidate": "tsx ./scripts/consolidateSnippets.ts"
16+
"snippets:consolidate": "tsx ./scripts/consolidateSnippets.ts",
17+
"prepare": "husky"
1718
},
1819
"keywords": [],
1920
"author": "",

backend/scripts/consolidateSnippets.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { slugify } from "@utils/slugify";
77

88
import { API_BASE } from "../index";
99
import { parseAllSnippets } from "./snippetParser";
10-
import { copyFolderSync } from "./copyStatic";
1110

1211
const dataPath = "data/consolidated/";
1312
const indexPath = join(dataPath, "_index.json");
@@ -59,5 +58,3 @@ for (const language of languages) {
5958
}
6059

6160
writeFileSync(indexPath, JSON.stringify(index, null, 4));
62-
63-
copyFolderSync("data", "dist/data");

backend/scripts/copyStatic.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ export function copyFolderSync(from: string, to: string) {
1515
}
1616
}
1717
}
18+
19+
copyFolderSync("data", "dist/data");

0 commit comments

Comments
 (0)