Skip to content

Commit 16353e1

Browse files
author
linfeng
committed
feat: update type check
1 parent ede0ce8 commit 16353e1

File tree

2 files changed

+24
-29
lines changed

2 files changed

+24
-29
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pri",
3-
"version": "3.3.28-beta.13",
3+
"version": "3.3.28-beta.14",
44
"types": "src/node/index.ts",
55
"main": "built/node/index.js",
66
"scripts": {
@@ -150,4 +150,4 @@
150150
"worker-loader": "2.0.0",
151151
"yargs": "13.2.4"
152152
}
153-
}
153+
}

src/utils/type-checker.ts

+22-27
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,36 @@ import { pri } from '../node';
44
import { logFatal, logInfo, logSuccess } from './log';
55

66
export function typeChecker() {
7-
const stashFileCnt = +execSync('git diff --cached --numstat --diff-filter=ACM | wc -l').toString('utf8');
7+
const stashFileCnt = +execSync('git diff --cached --numstat --diff-filter=ACM | wc -l').toString('utf8');
88

9-
if (stashFileCnt > 0) {
10-
let debugFiles = '';
9+
if (stashFileCnt > 0) {
10+
let debugFiles = '';
1111

12-
try {
13-
debugFiles = execSync(
14-
"grep -in '@DEBUG' --include *.ts --include *.tsx --include *.js --include *.scss --include *.css $(git diff --cached --name-only --diff-filter=ACM) /dev/null",
15-
{
16-
shell: 'bash',
17-
stdio: [0, 1],
18-
},
19-
).toString('utf8');
20-
// eslint-disable-next-line no-empty
21-
} catch (e) {}
12+
try {
13+
debugFiles = execSync(
14+
"grep -in '@DEBUG' --include *.ts --include *.tsx --include *.js --include *.scss --include *.css $(git diff --cached --name-only --diff-filter=ACM) /dev/null",
15+
{
16+
shell: 'bash',
17+
stdio: [0, 1],
18+
},
19+
).toString('utf8');
20+
// eslint-disable-next-line no-empty
21+
} catch (e) {}
2222

23-
if (debugFiles) {
24-
logFatal('@DEBUG identifier exists, the commit is terminated');
25-
process.exit(1);
23+
if (debugFiles) {
24+
logFatal('@DEBUG identifier exists, the commit is terminated');
25+
process.exit(1);
26+
}
2627
}
27-
}
2828

29-
const tsChangedFilesCnt = +execSync("git diff --cached --numstat --diff-filter=ACM | grep -F '.ts' | wc -l").toString(
30-
'utf8',
31-
);
32-
if (tsChangedFilesCnt) {
3329
logInfo('Checking TypeScript type, please wait');
3430
try {
35-
execSync(`${pri.projectRootPath}/node_modules/.bin/tsc -p . || exit 1`, {
36-
stdio: [0, 1, 2],
37-
});
31+
execSync(`${pri.projectRootPath}/node_modules/.bin/tsc -p . || exit 1`, {
32+
stdio: [0, 1, 2],
33+
});
3834
} catch (e) {
39-
logFatal('Type checks error!');
40-
process.exit(1);
35+
logFatal('Type checks error!');
36+
process.exit(1);
4137
}
4238
logSuccess('Type checks passed!');
43-
}
4439
}

0 commit comments

Comments
 (0)