1212}
1313
1414import * as fs from "fs" ;
15+ import * as path from "path" ;
1516import * as commandpost from "commandpost" ;
1617
1718import * as lib from "./" ;
@@ -29,6 +30,9 @@ interface RootOptions {
2930 editorconfig : boolean ;
3031 vscode : boolean ;
3132 tsfmt : boolean ;
33+ useTsconfig : string [ ] ;
34+ useTslint : string [ ] ;
35+ useTsfmt : string [ ] ;
3236 verbose : boolean ;
3337}
3438
@@ -48,6 +52,9 @@ let root = commandpost
4852 . option ( "--no-editorconfig" , "don't read a .editorconfig" )
4953 . option ( "--no-vscode" , "don't read a .vscode/settings.json" )
5054 . option ( "--no-tsfmt" , "don't read a tsfmt.json" )
55+ . option ( "--useTsconfig <path>" , "using specified config file insteaf of tsconfig.json" )
56+ . option ( "--useTslint <path>" , "using specified config file insteaf of tslint.json" )
57+ . option ( "--useTsfmt <path>" , "using specified config file insteaf of tsfmt.json" )
5158 . option ( "--verbose" , "makes output more verbose" )
5259 . action ( ( opts , args ) => {
5360 let replace = ! ! opts . replace ;
@@ -59,6 +66,9 @@ let root = commandpost
5966 let editorconfig = ! ! opts . editorconfig ;
6067 let vscode = ! ! opts . vscode ;
6168 let tsfmt = ! ! opts . tsfmt ;
69+ let tsconfigFile = opts . useTsconfig [ 0 ] ? path . join ( process . cwd ( ) , opts . useTsconfig [ 0 ] ) : null ;
70+ let tslintFile = opts . useTslint [ 0 ] ? path . join ( process . cwd ( ) , opts . useTslint [ 0 ] ) : null ;
71+ let tsfmtFile = opts . useTsfmt [ 0 ] ? path . join ( process . cwd ( ) , opts . useTsfmt [ 0 ] ) : null ;
6272 let verbose = ! ! opts . verbose ;
6373
6474 let files = args . files ;
@@ -86,10 +96,19 @@ let root = commandpost
8696 console . log ( "stdin: " + ( stdin ? "ON" : "OFF" ) ) ;
8797 console . log ( "files from tsconfig: " + ( useTsconfig ? "ON" : "OFF" ) ) ;
8898 console . log ( "tsconfig: " + ( tsconfig ? "ON" : "OFF" ) ) ;
99+ if ( tsconfigFile ) {
100+ console . log ( "specified tsconfig.json: " + tsconfigFile ) ;
101+ }
89102 console . log ( "tslint: " + ( tslint ? "ON" : "OFF" ) ) ;
103+ if ( tslintFile ) {
104+ console . log ( "specified tslint.json: " + tslintFile ) ;
105+ }
90106 console . log ( "editorconfig: " + ( editorconfig ? "ON" : "OFF" ) ) ;
91107 console . log ( "vscode: " + ( vscode ? "ON" : "OFF" ) ) ;
92108 console . log ( "tsfmt: " + ( tsfmt ? "ON" : "OFF" ) ) ;
109+ if ( tsfmtFile ) {
110+ console . log ( "specified tsfmt.json: " + tsfmtFile ) ;
111+ }
93112 }
94113
95114 if ( stdin ) {
@@ -103,10 +122,13 @@ let root = commandpost
103122 verify : verify ,
104123 baseDir : baseDir ,
105124 tsconfig : tsconfig ,
125+ tsconfigFile : tsconfigFile ,
106126 tslint : tslint ,
127+ tslintFile : tslintFile ,
107128 editorconfig : editorconfig ,
108129 vscode : vscode ,
109130 tsfmt : tsfmt ,
131+ tsfmtFile : tsfmtFile ,
110132 verbose : verbose ,
111133 } )
112134 . then ( result => {
@@ -123,10 +145,13 @@ let root = commandpost
123145 verify : verify ,
124146 baseDir : baseDir ,
125147 tsconfig : tsconfig ,
148+ tsconfigFile : tsconfigFile ,
126149 tslint : tslint ,
150+ tslintFile : tslintFile ,
127151 editorconfig : editorconfig ,
128152 vscode : vscode ,
129153 tsfmt : tsfmt ,
154+ tsfmtFile : tsfmtFile ,
130155 verbose : verbose ,
131156 } )
132157 . then ( showResultHandler )
0 commit comments