@@ -81,6 +81,7 @@ import {
8181 toPath ,
8282 toSorted ,
8383 tracing ,
84+ tscBuildOption ,
8485 validateLocaleAndSetLanguage ,
8586 version ,
8687 WatchCompilerHost ,
@@ -170,8 +171,8 @@ function shouldBePretty(sys: System, options: CompilerOptions | BuildOptions) {
170171function getOptionsForHelp ( commandLine : ParsedCommandLine ) {
171172 // Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
172173 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 ) ;
175176}
176177
177178function printVersion ( sys : System ) {
@@ -507,15 +508,15 @@ function printAllHelp(sys: System, compilerOptions: readonly CommandLineOption[]
507508 let output : string [ ] = [ ...getHeader ( sys , `${ getDiagnosticText ( Diagnostics . tsc_Colon_The_TypeScript_Compiler ) } - ${ getDiagnosticText ( Diagnostics . Version_0 , version ) } ` ) ] ;
508509 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" ) ) ] ;
509510 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" ) ) ] ;
511512 for ( const line of output ) {
512513 sys . write ( line ) ;
513514 }
514515}
515516
516517function printBuildHelp ( sys : System , buildOptions : readonly CommandLineOption [ ] ) {
517518 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" ) ) ] ;
519520 for ( const line of output ) {
520521 sys . write ( line ) ;
521522 }
@@ -559,11 +560,6 @@ function executeCommandLineWorker(
559560 commandLine : ParsedCommandLine ,
560561) {
561562 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-
567563 // Configuration file name (if any)
568564 let configFileName : string | undefined ;
569565 if ( commandLine . options . locale ) {
@@ -732,11 +728,11 @@ function executeCommandLineWorker(
732728 }
733729}
734730
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 [ ] ) {
737733 if ( commandLineArgs . length > 0 && commandLineArgs [ 0 ] . charCodeAt ( 0 ) === CharacterCodes . minus ) {
738734 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 ;
740736 }
741737 return false ;
742738}
@@ -749,8 +745,8 @@ export function executeCommandLine(
749745 cb : ExecuteCommandLineCallbacks ,
750746 commandLineArgs : readonly string [ ] ,
751747) : 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 ) ;
754750 if ( buildOptions . generateCpuProfile && system . enableCPUProfiler ) {
755751 system . enableCPUProfiler ( buildOptions . generateCpuProfile , ( ) =>
756752 performBuild (
0 commit comments