@@ -4,41 +4,36 @@ import { pri } from '../node';
44import { logFatal , logInfo , logSuccess } from './log' ;
55
66export 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