@@ -64,7 +64,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
6464 browser : process . env . browser || process . env . b || "IE" ,
6565 timeout : process . env . timeout || 40000 ,
6666 tests : process . env . test || process . env . tests || process . env . t ,
67- light : process . env . light || false ,
67+ light : process . env . light === undefined || process . env . light !== " false" ,
6868 reporter : process . env . reporter || process . env . r ,
6969 lint : process . env . lint || true ,
7070 files : process . env . f || process . env . file || process . env . files || "" ,
@@ -87,7 +87,7 @@ function possiblyQuote(cmd: string) {
8787}
8888
8989let useDebugMode = true ;
90- let host = cmdLineOptions [ " host" ] ;
90+ let host = cmdLineOptions . host ;
9191
9292// Constants
9393const compilerDirectory = "src/compiler/" ;
@@ -171,15 +171,32 @@ const librarySourceMap = [
171171 // JavaScript + all host library
172172 { target : "lib.d.ts" , sources : [ "header.d.ts" , "es5.d.ts" ] . concat ( hostsLibrarySources ) } ,
173173 { target : "lib.es6.d.ts" , sources : [ "header.d.ts" , "es5.d.ts" ] . concat ( es2015LibrarySources , hostsLibrarySources , "dom.iterable.d.ts" ) } ,
174- { target : "lib.es2016.full.d.ts" , sources : [ "header.d.ts" , "es2016.d.ts" ] . concat ( es2015LibrarySources , hostsLibrarySources , "dom.iterable.d.ts" ) } ,
175- { target : "lib.es2017.full.d.ts" , sources : [ "header.d.ts" , "es2017.d.ts" ] . concat ( es2015LibrarySources , hostsLibrarySources , "dom.iterable.d.ts" ) } ,
176- { target : "lib.esnext.full.d.ts" , sources : [ "header.d.ts" , "esnext.d.ts" ] . concat ( es2015LibrarySources , hostsLibrarySources , "dom.iterable.d.ts" ) } ,
174+ { target : "lib.es2016.full.d.ts" , sources : [ "header.d.ts" , "es2016.d.ts" ] . concat ( hostsLibrarySources , "dom.iterable.d.ts" ) } ,
175+ { target : "lib.es2017.full.d.ts" , sources : [ "header.d.ts" , "es2017.d.ts" ] . concat ( hostsLibrarySources , "dom.iterable.d.ts" ) } ,
176+ { target : "lib.esnext.full.d.ts" , sources : [ "header.d.ts" , "esnext.d.ts" ] . concat ( hostsLibrarySources , "dom.iterable.d.ts" ) } ,
177177] . concat ( es2015LibrarySourceMap , es2016LibrarySourceMap , es2017LibrarySourceMap , esnextLibrarySourceMap ) ;
178178
179179const libraryTargets = librarySourceMap . map ( function ( f ) {
180180 return path . join ( builtLocalDirectory , f . target ) ;
181181} ) ;
182182
183+ /**
184+ * .lcg file is what localization team uses to know what messages to localize.
185+ * The file is always generated in 'enu\diagnosticMessages.generated.json.lcg'
186+ */
187+ const generatedLCGFile = path . join ( builtLocalDirectory , "enu" , "diagnosticMessages.generated.json.lcg" ) ;
188+
189+ /**
190+ * The localization target produces the two following transformations:
191+ * 1. 'src\loc\lcl\<locale>\diagnosticMessages.generated.json.lcl' => 'built\local\<locale>\diagnosticMessages.generated.json'
192+ * convert localized resources into a .json file the compiler can understand
193+ * 2. 'src\compiler\diagnosticMessages.generated.json' => 'built\local\ENU\diagnosticMessages.generated.json.lcg'
194+ * generate the lcg file (source of messages to localize) from the diagnosticMessages.generated.json
195+ */
196+ const localizationTargets = [ "cs" , "de" , "es" , "fr" , "it" , "ja" , "ko" , "pl" , "pt-BR" , "ru" , "tr" , "zh-CN" , "zh-TW" ] . map ( function ( f ) {
197+ return path . join ( builtLocalDirectory , f , "diagnosticMessages.generated.json" ) ;
198+ } ) . concat ( generatedLCGFile ) ;
199+
183200for ( const i in libraryTargets ) {
184201 const entry = librarySourceMap [ i ] ;
185202 const target = libraryTargets [ i ] ;
@@ -398,7 +415,6 @@ gulp.task(generateLocalizedDiagnosticMessagesJs, /*help*/ false, [], () => {
398415} ) ;
399416
400417// Localize diagnostics
401- const generatedLCGFile = path . join ( builtLocalDirectory , "enu" , "diagnosticMessages.generated.json.lcg" ) ;
402418gulp . task ( generatedLCGFile , [ generateLocalizedDiagnosticMessagesJs , diagnosticInfoMapTs ] , ( done ) => {
403419 if ( fs . existsSync ( builtLocalDirectory ) && needsUpdate ( generatedDiagnosticMessagesJSON , generatedLCGFile ) ) {
404420 exec ( host , [ generateLocalizedDiagnosticMessagesJs , lclDirectory , builtLocalDirectory , generatedDiagnosticMessagesJSON ] , done , done ) ;
@@ -576,8 +592,7 @@ gulp.task("dontUseDebugMode", /*help*/ false, [], (done) => { useDebugMode = fal
576592gulp . task ( "VerifyLKG" , /*help*/ false , [ ] , ( ) => {
577593 const expectedFiles = [ builtLocalCompiler , servicesFile , serverFile , nodePackageFile , nodeDefinitionsFile , standaloneDefinitionsFile , tsserverLibraryFile , tsserverLibraryDefinitionFile , typingsInstallerJs , cancellationTokenJs ] . concat ( libraryTargets ) ;
578594 const missingFiles = expectedFiles .
579- concat ( fs . readdirSync ( lclDirectory ) . map ( function ( d ) { return path . join ( builtLocalDirectory , d , "diagnosticMessages.generated.json" ) ; } ) ) .
580- concat ( generatedLCGFile ) .
595+ concat ( localizationTargets ) .
581596 filter ( f => ! fs . existsSync ( f ) ) ;
582597 if ( missingFiles . length > 0 ) {
583598 throw new Error ( "Cannot replace the LKG unless all built targets are present in directory " + builtLocalDirectory +
@@ -636,15 +651,15 @@ function restoreSavedNodeEnv() {
636651}
637652
638653function runConsoleTests ( defaultReporter : string , runInParallel : boolean , done : ( e ?: any ) => void ) {
639- const lintFlag = cmdLineOptions [ " lint" ] ;
654+ const lintFlag = cmdLineOptions . lint ;
640655 cleanTestDirs ( ( err ) => {
641656 if ( err ) { console . error ( err ) ; failWithStatus ( err , 1 ) ; }
642- let testTimeout = cmdLineOptions [ " timeout" ] ;
643- const debug = cmdLineOptions [ " debug" ] ;
644- const inspect = cmdLineOptions [ " inspect" ] ;
645- const tests = cmdLineOptions [ " tests" ] ;
646- const light = cmdLineOptions [ " light" ] ;
647- const stackTraceLimit = cmdLineOptions [ " stackTraceLimit" ] ;
657+ let testTimeout = cmdLineOptions . timeout ;
658+ const debug = cmdLineOptions . debug ;
659+ const inspect = cmdLineOptions . inspect ;
660+ const tests = cmdLineOptions . tests ;
661+ const light = cmdLineOptions . light ;
662+ const stackTraceLimit = cmdLineOptions . stackTraceLimit ;
648663 const testConfigFile = "test.config" ;
649664 if ( fs . existsSync ( testConfigFile ) ) {
650665 fs . unlinkSync ( testConfigFile ) ;
@@ -660,7 +675,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
660675 } while ( fs . existsSync ( taskConfigsFolder ) ) ;
661676 fs . mkdirSync ( taskConfigsFolder ) ;
662677
663- workerCount = cmdLineOptions [ " workers" ] ;
678+ workerCount = cmdLineOptions . workers ;
664679 }
665680
666681 if ( tests || light || taskConfigsFolder ) {
@@ -671,8 +686,8 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
671686 testTimeout = 400000 ;
672687 }
673688
674- const colors = cmdLineOptions [ " colors" ] ;
675- const reporter = cmdLineOptions [ " reporter" ] || defaultReporter ;
689+ const colors = cmdLineOptions . colors ;
690+ const reporter = cmdLineOptions . reporter || defaultReporter ;
676691
677692 // timeout normally isn"t necessary but Travis-CI has been timing out on compiler baselines occasionally
678693 // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
@@ -860,7 +875,7 @@ function cleanTestDirs(done: (e?: any) => void) {
860875
861876// used to pass data from jake command line directly to run.js
862877function writeTestConfigFile ( tests : string , light : boolean , taskConfigsFolder ?: string , workerCount ?: number , stackTraceLimit ?: string ) {
863- const testConfigContents = JSON . stringify ( { test : tests ? [ tests ] : undefined , light, workerCount, stackTraceLimit, taskConfigsFolder, noColor : ! cmdLineOptions [ " colors" ] } ) ;
878+ const testConfigContents = JSON . stringify ( { test : tests ? [ tests ] : undefined , light, workerCount, stackTraceLimit, taskConfigsFolder, noColor : ! cmdLineOptions . colors } ) ;
864879 console . log ( "Running tests with config: " + testConfigContents ) ;
865880 fs . writeFileSync ( "test.config" , testConfigContents ) ;
866881}
@@ -870,8 +885,8 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
870885 cleanTestDirs ( ( err ) => {
871886 if ( err ) { console . error ( err ) ; done ( err ) ; process . exit ( 1 ) ; }
872887 host = "node" ;
873- const tests = cmdLineOptions [ " tests" ] ;
874- const light = cmdLineOptions [ " light" ] ;
888+ const tests = cmdLineOptions . tests ;
889+ const light = cmdLineOptions . light ;
875890 const testConfigFile = "test.config" ;
876891 if ( fs . existsSync ( testConfigFile ) ) {
877892 fs . unlinkSync ( testConfigFile ) ;
@@ -881,8 +896,8 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
881896 }
882897
883898 const args = [ nodeServerOutFile ] ;
884- if ( cmdLineOptions [ " browser" ] ) {
885- args . push ( cmdLineOptions [ " browser" ] ) ;
899+ if ( cmdLineOptions . browser ) {
900+ args . push ( cmdLineOptions . browser ) ;
886901 }
887902 if ( tests ) {
888903 args . push ( JSON . stringify ( tests ) ) ;
@@ -892,13 +907,13 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
892907} ) ;
893908
894909gulp . task ( "generate-code-coverage" , "Generates code coverage data via istanbul" , [ "tests" ] , ( done ) => {
895- const testTimeout = cmdLineOptions [ " timeout" ] ;
910+ const testTimeout = cmdLineOptions . timeout ;
896911 exec ( "istanbul" , [ "cover" , "node_modules/mocha/bin/_mocha" , "--" , "-R" , "min" , "-t" , testTimeout . toString ( ) , run ] , done , done ) ;
897912} ) ;
898913
899914
900915function getDiffTool ( ) {
901- const program = process . env [ " DIFF" ] ;
916+ const program = process . env . DIFF ;
902917 if ( ! program ) {
903918 console . error ( "Add the 'DIFF' environment variable to the path of the program you want to use." ) ;
904919 process . exit ( 1 ) ;
@@ -1019,7 +1034,7 @@ gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => {
10191034} ) ;
10201035
10211036gulp . task ( "tsc-instrumented" , "Builds an instrumented tsc.js - run with --test=[testname]" , [ "local" , loggedIOJsPath , instrumenterJsPath , servicesFile ] , ( done ) => {
1022- const test = cmdLineOptions [ " tests" ] || "iocapture" ;
1037+ const test = cmdLineOptions . tests || "iocapture" ;
10231038 exec ( host , [ instrumenterJsPath , "record" , test , builtLocalCompiler ] , done , done ) ;
10241039} ) ;
10251040
@@ -1088,7 +1103,7 @@ function spawnLintWorker(files: {path: string}[], callback: (failures: number) =
10881103
10891104gulp . task ( "lint" , "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex" , [ "build-rules" ] , ( ) => {
10901105 if ( fold . isTravis ( ) ) console . log ( fold . start ( "lint" ) ) ;
1091- const fileMatcher = cmdLineOptions [ " files" ] ;
1106+ const fileMatcher = cmdLineOptions . files ;
10921107 const files = fileMatcher
10931108 ? `src/**/${ fileMatcher } `
10941109 : "Gulpfile.ts 'scripts/generateLocalizedDiagnosticMessages.ts' 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'" ;
0 commit comments