Skip to content

Commit f039280

Browse files
authored
ci: add job to check types (#4315)
* chore: add script to check types * ci: check types
1 parent 78ebe7f commit f039280

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

.github/workflows/nodejs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
- name: Lint
4444
run: npm run lint
4545

46+
- name: Check types
47+
run: npm run check:types
48+
4649
- name: Security audit
4750
run: npm audit --production
4851

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"build:client": "rimraf ./client/* && babel client-src/ --out-dir client/ --ignore \"client-src/webpack.config.js\" --ignore \"client-src/modules\" && webpack --config client-src/webpack.config.js",
2727
"build:types": "rimraf ./types/* && tsc --declaration --emitDeclarationOnly --outDir types && node ./scripts/extend-webpack-types.js && prettier \"types/**/*.ts\" --write && prettier \"types/**/*.ts\" --write",
2828
"build": "npm-run-all -p \"build:**\"",
29+
"check:types": "node ./scripts/check-types.js",
2930
"test:only": "jest",
3031
"test:coverage": "npm run test:only -- --coverage",
3132
"test:watch": "npm run test:coverage --watch",

scripts/check-types.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"use strict";
2+
3+
// eslint-disable-next-line import/no-extraneous-dependencies
4+
const { sync } = require("execa");
5+
6+
try {
7+
sync("npm run build:types", [], {
8+
cwd: __dirname,
9+
reject: false,
10+
shell: true,
11+
});
12+
13+
const { stdout } = sync("git status --porcelain", [], {
14+
shell: true,
15+
});
16+
17+
if (!stdout.trim().includes("types/")) {
18+
// eslint-disable-next-line no-console
19+
console.log("types are up-to-date.");
20+
process.exit(0);
21+
} else {
22+
// eslint-disable-next-line no-console
23+
console.log(`Please update types by running "npm run build:types"`);
24+
process.exit(2);
25+
}
26+
} catch (error) {
27+
// eslint-disable-next-line no-console
28+
console.error(error);
29+
process.exit(2);
30+
}

0 commit comments

Comments
 (0)