@@ -81,6 +81,7 @@ import {
81
81
toPath ,
82
82
toSorted ,
83
83
tracing ,
84
+ tscBuildOption ,
84
85
validateLocaleAndSetLanguage ,
85
86
version ,
86
87
WatchCompilerHost ,
@@ -170,8 +171,8 @@ function shouldBePretty(sys: System, options: CompilerOptions | BuildOptions) {
170
171
function getOptionsForHelp ( commandLine : ParsedCommandLine ) {
171
172
// Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
172
173
return ! ! commandLine . options . all ?
173
- toSorted ( optionDeclarations , ( a , b ) => compareStringsCaseInsensitive ( a . name , b . name ) ) :
174
- filter ( optionDeclarations . slice ( ) , v => ! ! v . showInSimplifiedHelpView ) ;
174
+ toSorted ( optionDeclarations . concat ( tscBuildOption ) , ( a , b ) => compareStringsCaseInsensitive ( a . name , b . name ) ) :
175
+ filter ( optionDeclarations . concat ( tscBuildOption ) , v => ! ! v . showInSimplifiedHelpView ) ;
175
176
}
176
177
177
178
function printVersion ( sys : System ) {
@@ -507,15 +508,15 @@ function printAllHelp(sys: System, compilerOptions: readonly CommandLineOption[]
507
508
let output : string [ ] = [ ...getHeader ( sys , `${ getDiagnosticText ( Diagnostics . tsc_Colon_The_TypeScript_Compiler ) } - ${ getDiagnosticText ( Diagnostics . Version_0 , version ) } ` ) ] ;
508
509
output = [ ...output , ...generateSectionOptionsOutput ( sys , getDiagnosticText ( Diagnostics . ALL_COMPILER_OPTIONS ) , compilerOptions , /*subCategory*/ true , /*beforeOptionsDescription*/ undefined , formatMessage ( Diagnostics . You_can_learn_about_all_of_the_compiler_options_at_0 , "https://aka.ms/tsc" ) ) ] ;
509
510
output = [ ...output , ...generateSectionOptionsOutput ( sys , getDiagnosticText ( Diagnostics . WATCH_OPTIONS ) , watchOptions , /*subCategory*/ false , getDiagnosticText ( Diagnostics . Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon ) ) ] ;
510
- output = [ ...output , ...generateSectionOptionsOutput ( sys , getDiagnosticText ( Diagnostics . BUILD_OPTIONS ) , buildOptions , /*subCategory*/ false , formatMessage ( Diagnostics . Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0 , "https://aka.ms/tsc-composite-builds" ) ) ] ;
511
+ output = [ ...output , ...generateSectionOptionsOutput ( sys , getDiagnosticText ( Diagnostics . BUILD_OPTIONS ) , filter ( buildOptions , option => option !== tscBuildOption ) , /*subCategory*/ false , formatMessage ( Diagnostics . Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0 , "https://aka.ms/tsc-composite-builds" ) ) ] ;
511
512
for ( const line of output ) {
512
513
sys . write ( line ) ;
513
514
}
514
515
}
515
516
516
517
function printBuildHelp ( sys : System , buildOptions : readonly CommandLineOption [ ] ) {
517
518
let output : string [ ] = [ ...getHeader ( sys , `${ getDiagnosticText ( Diagnostics . tsc_Colon_The_TypeScript_Compiler ) } - ${ getDiagnosticText ( Diagnostics . Version_0 , version ) } ` ) ] ;
518
- output = [ ...output , ...generateSectionOptionsOutput ( sys , getDiagnosticText ( Diagnostics . BUILD_OPTIONS ) , buildOptions , /*subCategory*/ false , formatMessage ( Diagnostics . Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0 , "https://aka.ms/tsc-composite-builds" ) ) ] ;
519
+ output = [ ...output , ...generateSectionOptionsOutput ( sys , getDiagnosticText ( Diagnostics . BUILD_OPTIONS ) , filter ( buildOptions , option => option !== tscBuildOption ) , /*subCategory*/ false , formatMessage ( Diagnostics . Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0 , "https://aka.ms/tsc-composite-builds" ) ) ] ;
519
520
for ( const line of output ) {
520
521
sys . write ( line ) ;
521
522
}
@@ -559,11 +560,6 @@ function executeCommandLineWorker(
559
560
commandLine : ParsedCommandLine ,
560
561
) {
561
562
let reportDiagnostic = createDiagnosticReporter ( sys ) ;
562
- if ( commandLine . options . build ) {
563
- reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Option_build_must_be_the_first_command_line_argument ) ) ;
564
- return sys . exit ( ExitStatus . DiagnosticsPresent_OutputsSkipped ) ;
565
- }
566
-
567
563
// Configuration file name (if any)
568
564
let configFileName : string | undefined ;
569
565
if ( commandLine . options . locale ) {
@@ -732,11 +728,11 @@ function executeCommandLineWorker(
732
728
}
733
729
}
734
730
735
- /** @internal */
736
- export function isBuild ( commandLineArgs : readonly string [ ] ) {
731
+ /** Returns true if commandline is --build and needs to be parsed useing parseBuildCommand */
732
+ export function isBuildCommand ( commandLineArgs : readonly string [ ] ) {
737
733
if ( commandLineArgs . length > 0 && commandLineArgs [ 0 ] . charCodeAt ( 0 ) === CharacterCodes . minus ) {
738
734
const firstOption = commandLineArgs [ 0 ] . slice ( commandLineArgs [ 0 ] . charCodeAt ( 1 ) === CharacterCodes . minus ? 2 : 1 ) . toLowerCase ( ) ;
739
- return firstOption === "build" || firstOption === "b" ;
735
+ return firstOption === tscBuildOption . name || firstOption === tscBuildOption . shortName ;
740
736
}
741
737
return false ;
742
738
}
@@ -749,8 +745,8 @@ export function executeCommandLine(
749
745
cb : ExecuteCommandLineCallbacks ,
750
746
commandLineArgs : readonly string [ ] ,
751
747
) : void | SolutionBuilder < EmitAndSemanticDiagnosticsBuilderProgram > | WatchOfConfigFile < EmitAndSemanticDiagnosticsBuilderProgram > {
752
- if ( isBuild ( commandLineArgs ) ) {
753
- const { buildOptions, watchOptions, projects, errors } = parseBuildCommand ( commandLineArgs . slice ( 1 ) ) ;
748
+ if ( isBuildCommand ( commandLineArgs ) ) {
749
+ const { buildOptions, watchOptions, projects, errors } = parseBuildCommand ( commandLineArgs ) ;
754
750
if ( buildOptions . generateCpuProfile && system . enableCPUProfiler ) {
755
751
system . enableCPUProfiler ( buildOptions . generateCpuProfile , ( ) =>
756
752
performBuild (
0 commit comments