@@ -54,15 +54,7 @@ namespace ts {
54
54
55
55
export function executeCommandLine ( args : string [ ] ) : void {
56
56
if ( args . length > 0 && ( ( args [ 0 ] . toLowerCase ( ) === "--build" ) || ( args [ 0 ] . toLowerCase ( ) === "-b" ) ) ) {
57
- const reportDiag = createDiagnosticReporter ( sys , defaultIsPretty ( ) ) ;
58
- const report = ( message : DiagnosticMessage , ...args : string [ ] ) => reportDiag ( createCompilerDiagnostic ( message , ...args ) ) ;
59
- const buildHost : BuildHost = {
60
- error : report ,
61
- verbose : report ,
62
- message : report ,
63
- errorDiagnostic : d => reportDiag ( d )
64
- } ;
65
- const result = performBuild ( args . slice ( 1 ) , createCompilerHost ( { } ) , buildHost ) ;
57
+ const result = performBuild ( args . slice ( 1 ) ) ;
66
58
// undefined = in watch mode, do not exit
67
59
if ( result !== undefined ) {
68
60
return sys . exit ( result ) ;
@@ -172,7 +164,7 @@ namespace ts {
172
164
}
173
165
}
174
166
175
- function performBuild ( args : string [ ] , compilerHost : CompilerHost , buildHost : BuildHost ) : number | undefined {
167
+ function performBuild ( args : string [ ] ) : number | undefined {
176
168
const buildOpts : CommandLineOption [ ] = [
177
169
{
178
170
name : "help" ,
@@ -243,24 +235,28 @@ namespace ts {
243
235
}
244
236
245
237
if ( buildOptions . help ) {
246
- printHelp ( buildOpts , "--build " ) ; return ExitStatus . Success ;
238
+ printHelp ( buildOpts , "--build " ) ;
239
+ return ExitStatus . Success ;
247
240
}
248
241
242
+ // Update to pretty if host supports it
243
+ updateReportDiagnostic ( { } ) ;
244
+
249
245
// Nonsensical combinations
250
246
if ( buildOptions . clean && buildOptions . force ) {
251
- buildHost . error ( Diagnostics . Options_0_and_1_cannot_be_combined , "clean" , "force" ) ;
247
+ reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Options_0_and_1_cannot_be_combined , "clean" , "force" ) ) ;
252
248
return ExitStatus . DiagnosticsPresent_OutputsSkipped ;
253
249
}
254
250
if ( buildOptions . clean && buildOptions . verbose ) {
255
- buildHost . error ( Diagnostics . Options_0_and_1_cannot_be_combined , "clean" , "verbose" ) ;
251
+ reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Options_0_and_1_cannot_be_combined , "clean" , "verbose" ) ) ;
256
252
return ExitStatus . DiagnosticsPresent_OutputsSkipped ;
257
253
}
258
254
if ( buildOptions . clean && buildOptions . watch ) {
259
- buildHost . error ( Diagnostics . Options_0_and_1_cannot_be_combined , "clean" , "watch" ) ;
255
+ reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Options_0_and_1_cannot_be_combined , "clean" , "watch" ) ) ;
260
256
return ExitStatus . DiagnosticsPresent_OutputsSkipped ;
261
257
}
262
258
if ( buildOptions . watch && buildOptions . dry ) {
263
- buildHost . error ( Diagnostics . Options_0_and_1_cannot_be_combined , "watch" , "dry" ) ;
259
+ reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Options_0_and_1_cannot_be_combined , "watch" , "dry" ) ) ;
264
260
return ExitStatus . DiagnosticsPresent_OutputsSkipped ;
265
261
}
266
262
@@ -269,7 +265,15 @@ namespace ts {
269
265
addProject ( "." ) ;
270
266
}
271
267
272
- const builder = createSolutionBuilder ( compilerHost , buildHost , projects , buildOptions ) ;
268
+ const report = ( message : DiagnosticMessage , ...args : string [ ] ) => reportDiagnostic ( createCompilerDiagnostic ( message , ...args ) ) ;
269
+ const buildHost : BuildHost = {
270
+ error : report ,
271
+ verbose : report ,
272
+ message : report ,
273
+ errorDiagnostic : d => reportDiagnostic ( d )
274
+ } ;
275
+
276
+ const builder = createSolutionBuilder ( createCompilerHost ( { } ) , buildHost , projects , buildOptions ) ;
273
277
if ( buildOptions . clean ) {
274
278
return builder . cleanAllProjects ( ) ;
275
279
}
@@ -283,9 +287,9 @@ namespace ts {
283
287
return builder . buildAllProjects ( ) ;
284
288
285
289
function addProject ( projectSpecification : string ) {
286
- const fileName = resolvePath ( compilerHost . getCurrentDirectory ( ) , projectSpecification ) ;
287
- const refPath = resolveProjectReferencePath ( compilerHost , { path : fileName } ) ;
288
- if ( ! compilerHost . fileExists ( refPath ) ) {
290
+ const fileName = resolvePath ( sys . getCurrentDirectory ( ) , projectSpecification ) ;
291
+ const refPath = resolveProjectReferencePath ( sys , { path : fileName } ) ;
292
+ if ( ! sys . fileExists ( refPath ) ) {
289
293
return buildHost . error ( Diagnostics . File_0_does_not_exist , fileName ) ;
290
294
}
291
295
projects . push ( refPath ) ;
0 commit comments