@@ -53,14 +53,10 @@ namespace ts {
53
53
}
54
54
55
55
export function executeCommandLine ( args : string [ ] ) : void {
56
- if ( args . length > 0 && ( ( args [ 0 ] . toLowerCase ( ) === "--build" ) || ( args [ 0 ] . toLowerCase ( ) === "-b" ) ) ) {
57
- const result = performBuild ( args . slice ( 1 ) ) ;
58
- // undefined = in watch mode, do not exit
59
- if ( result !== undefined ) {
60
- return sys . exit ( result ) ;
61
- }
62
- else {
63
- return ;
56
+ if ( args . length > 0 && args [ 0 ] . charCodeAt ( 0 ) === CharacterCodes . minus ) {
57
+ const firstOption = args [ 0 ] . slice ( args [ 0 ] . charCodeAt ( 1 ) === CharacterCodes . minus ? 2 : 1 ) . toLowerCase ( ) ;
58
+ if ( firstOption === "build" || firstOption === "b" ) {
59
+ return performBuild ( args . slice ( 1 ) ) ;
64
60
}
65
61
}
66
62
@@ -164,30 +160,30 @@ namespace ts {
164
160
}
165
161
}
166
162
167
- function performBuild ( args : string [ ] ) : number | undefined {
163
+ function performBuild ( args : string [ ] ) {
168
164
const { buildOptions, projects, errors } = parseBuildCommand ( args ) ;
169
165
if ( errors . length > 0 ) {
170
166
errors . forEach ( reportDiagnostic ) ;
171
- return ExitStatus . DiagnosticsPresent_OutputsSkipped ;
167
+ return sys . exit ( ExitStatus . DiagnosticsPresent_OutputsSkipped ) ;
172
168
}
173
169
174
170
if ( buildOptions . help ) {
175
171
printVersion ( ) ;
176
172
printHelp ( buildOpts , "--build " ) ;
177
- return ExitStatus . Success ;
173
+ return sys . exit ( ExitStatus . Success ) ;
178
174
}
179
175
180
176
// Update to pretty if host supports it
181
177
updateReportDiagnostic ( ) ;
182
178
if ( projects . length === 0 ) {
183
179
printVersion ( ) ;
184
180
printHelp ( buildOpts , "--build " ) ;
185
- return ExitStatus . Success ;
181
+ return sys . exit ( ExitStatus . Success ) ;
186
182
}
187
183
188
184
if ( ! sys . getModifiedTime || ! sys . setModifiedTime || ( buildOptions . clean && ! sys . deleteFile ) ) {
189
185
reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . The_current_host_does_not_support_the_0_option , "--build" ) ) ;
190
- return ExitStatus . DiagnosticsPresent_OutputsSkipped ;
186
+ return sys . exit ( ExitStatus . DiagnosticsPresent_OutputsSkipped ) ;
191
187
}
192
188
if ( buildOptions . watch ) {
193
189
reportWatchModeWithoutSysSupport ( ) ;
@@ -196,16 +192,15 @@ namespace ts {
196
192
// TODO: change this to host if watch => watchHost otherwiue without wathc
197
193
const builder = createSolutionBuilder ( createSolutionBuilderWithWatchHost ( sys , reportDiagnostic , createBuilderStatusReporter ( sys , shouldBePretty ( ) ) , createWatchStatusReporter ( ) ) , projects , buildOptions ) ;
198
194
if ( buildOptions . clean ) {
199
- return builder . cleanAllProjects ( ) ;
195
+ return sys . exit ( builder . cleanAllProjects ( ) ) ;
200
196
}
201
197
202
198
if ( buildOptions . watch ) {
203
199
builder . buildAllProjects ( ) ;
204
- builder . startWatching ( ) ;
205
- return undefined ;
200
+ return builder . startWatching ( ) ;
206
201
}
207
202
208
- return builder . buildAllProjects ( ) ;
203
+ return sys . exit ( builder . buildAllProjects ( ) ) ;
209
204
}
210
205
211
206
function performCompilation ( rootNames : string [ ] , projectReferences : ReadonlyArray < ProjectReference > | undefined , options : CompilerOptions , configFileParsingDiagnostics ?: ReadonlyArray < Diagnostic > ) {
0 commit comments