@@ -83,25 +83,51 @@ let root = commandpost
83
83
}
84
84
85
85
if ( verbose ) {
86
- console . log ( "replace: " + ( replace ? "ON" : "OFF" ) ) ;
87
- console . log ( "verify: " + ( verify ? "ON" : "OFF" ) ) ;
88
- console . log ( "baseDir: " + ( baseDir ? baseDir : process . cwd ( ) ) ) ;
89
- console . log ( "stdin: " + ( stdin ? "ON" : "OFF" ) ) ;
90
- console . log ( "files from tsconfig: " + ( useTsconfig ? "ON" : "OFF" ) ) ;
91
- console . log ( "tsconfig: " + ( tsconfig ? "ON" : "OFF" ) ) ;
86
+ const printPool : { [ name : string ] : string ; } = { } ;
87
+ const printSetting = ( name : string , value : string | boolean ) => {
88
+ if ( typeof value === "boolean" ) {
89
+ printPool [ name ] = value ? "ON" : "OFF" ;
90
+ } else {
91
+ printPool [ name ] = value ;
92
+ }
93
+ } ;
94
+ const doPrint = ( ) => {
95
+ const maxLength = Object . keys ( printPool ) . reduce ( ( p , c ) => Math . max ( p , c . length ) , 0 ) ;
96
+ Object . keys ( printPool ) . forEach ( key => {
97
+ const value = printPool [ key ] ;
98
+ console . log ( `${ padSpaces ( key , maxLength + 1 ) } : ${ value } ` ) ;
99
+ } ) ;
100
+
101
+ function padSpaces ( str : string , len : number ) {
102
+ let result = str ;
103
+ while ( result . length < len ) {
104
+ result += " " ;
105
+ }
106
+ return result ;
107
+ }
108
+ } ;
109
+
110
+ printSetting ( "replace" , replace ) ;
111
+ printSetting ( "verify" , verify ) ;
112
+ printSetting ( "baseDir" , baseDir ? baseDir : process . cwd ( ) ) ;
113
+ printSetting ( "stdin" , stdin ) ;
114
+ printSetting ( "files from tsconfig" , useTsconfig ) ;
115
+ printSetting ( "tsconfig" , tsconfig ) ;
92
116
if ( tsconfigFile ) {
93
- console . log ( "specified tsconfig.json: " + tsconfigFile ) ;
117
+ printSetting ( "specified tsconfig.json" , tsconfigFile ) ;
94
118
}
95
- console . log ( "tslint: " + ( tslint ? "ON" : "OFF" ) ) ;
119
+ printSetting ( "tslint" , tslint ) ;
96
120
if ( tslintFile ) {
97
- console . log ( "specified tslint.json: " + tslintFile ) ;
121
+ printSetting ( "specified tslint.json" , tslintFile ) ;
98
122
}
99
- console . log ( "editorconfig: " + ( editorconfig ? "ON" : "OFF" ) ) ;
100
- console . log ( "vscode: " + ( vscode ? "ON" : "OFF" ) ) ;
101
- console . log ( "tsfmt: " + ( tsfmt ? "ON" : "OFF" ) ) ;
123
+ printSetting ( "editorconfig" , editorconfig ) ;
124
+ printSetting ( "vscode" , vscode ) ;
125
+ printSetting ( "tsfmt" , tsfmt ) ;
102
126
if ( tsfmtFile ) {
103
- console . log ( "specified tsfmt.json: " + tsfmtFile ) ;
127
+ printSetting ( "specified tsfmt.json" , tsfmtFile ) ;
104
128
}
129
+
130
+ doPrint ( ) ;
105
131
}
106
132
107
133
if ( stdin ) {
0 commit comments