File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 17
17
import * as meow from 'meow' ;
18
18
import * as updateNotifier from 'update-notifier' ;
19
19
import { init } from './init' ;
20
- import { lint } from './lint' ;
21
- import { format } from './format' ;
22
20
import { clean } from './clean' ;
23
21
24
22
export interface Logger {
@@ -35,6 +33,9 @@ export interface Options {
35
33
logger: Logger ;
36
34
}
37
35
36
+ export type VerbFunction = ( options : Options , fix ? : boolean ) =>
37
+ Promise < boolean > ;
38
+
38
39
const logger : Logger = console ;
39
40
40
41
const cli = meow ( `
@@ -74,9 +75,15 @@ async function run(verb: string): Promise<boolean> {
74
75
yes : cli . flags . yes || cli . flags . y || false ,
75
76
logger : logger
76
77
} ;
78
+ // Linting/formatting depend on typescript. We don't want to load the
79
+ // typescript module during init, since it might not exist.
80
+ // See: https://github.com/google/ts-style/issues/48
81
+ if ( verb === 'init' ) {
82
+ return await init ( options ) ;
83
+ }
84
+ const lint : VerbFunction = require ( './lint' ) ;
85
+ const format : VerbFunction = require ( './format' ) ;
77
86
switch ( verb ) {
78
- case 'init ':
79
- return await init ( options ) ;
80
87
case 'check ':
81
88
return ( await lint ( options ) && await format ( options ) ) ;
82
89
case 'fix ':
You can’t perform that action at this time.
0 commit comments