@@ -64,7 +64,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
64
64
browser : process . env . browser || process . env . b || "IE" ,
65
65
timeout : process . env . timeout || 40000 ,
66
66
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" ,
68
68
reporter : process . env . reporter || process . env . r ,
69
69
lint : process . env . lint || true ,
70
70
files : process . env . f || process . env . file || process . env . files || "" ,
@@ -87,7 +87,7 @@ function possiblyQuote(cmd: string) {
87
87
}
88
88
89
89
let useDebugMode = true ;
90
- let host = cmdLineOptions [ " host" ] ;
90
+ let host = cmdLineOptions . host ;
91
91
92
92
// Constants
93
93
const compilerDirectory = "src/compiler/" ;
@@ -171,15 +171,32 @@ const librarySourceMap = [
171
171
// JavaScript + all host library
172
172
{ target : "lib.d.ts" , sources : [ "header.d.ts" , "es5.d.ts" ] . concat ( hostsLibrarySources ) } ,
173
173
{ 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" ) } ,
177
177
] . concat ( es2015LibrarySourceMap , es2016LibrarySourceMap , es2017LibrarySourceMap , esnextLibrarySourceMap ) ;
178
178
179
179
const libraryTargets = librarySourceMap . map ( function ( f ) {
180
180
return path . join ( builtLocalDirectory , f . target ) ;
181
181
} ) ;
182
182
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
+
183
200
for ( const i in libraryTargets ) {
184
201
const entry = librarySourceMap [ i ] ;
185
202
const target = libraryTargets [ i ] ;
@@ -398,7 +415,6 @@ gulp.task(generateLocalizedDiagnosticMessagesJs, /*help*/ false, [], () => {
398
415
} ) ;
399
416
400
417
// Localize diagnostics
401
- const generatedLCGFile = path . join ( builtLocalDirectory , "enu" , "diagnosticMessages.generated.json.lcg" ) ;
402
418
gulp . task ( generatedLCGFile , [ generateLocalizedDiagnosticMessagesJs , diagnosticInfoMapTs ] , ( done ) => {
403
419
if ( fs . existsSync ( builtLocalDirectory ) && needsUpdate ( generatedDiagnosticMessagesJSON , generatedLCGFile ) ) {
404
420
exec ( host , [ generateLocalizedDiagnosticMessagesJs , lclDirectory , builtLocalDirectory , generatedDiagnosticMessagesJSON ] , done , done ) ;
@@ -576,8 +592,7 @@ gulp.task("dontUseDebugMode", /*help*/ false, [], (done) => { useDebugMode = fal
576
592
gulp . task ( "VerifyLKG" , /*help*/ false , [ ] , ( ) => {
577
593
const expectedFiles = [ builtLocalCompiler , servicesFile , serverFile , nodePackageFile , nodeDefinitionsFile , standaloneDefinitionsFile , tsserverLibraryFile , tsserverLibraryDefinitionFile , typingsInstallerJs , cancellationTokenJs ] . concat ( libraryTargets ) ;
578
594
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 ) .
581
596
filter ( f => ! fs . existsSync ( f ) ) ;
582
597
if ( missingFiles . length > 0 ) {
583
598
throw new Error ( "Cannot replace the LKG unless all built targets are present in directory " + builtLocalDirectory +
@@ -636,15 +651,15 @@ function restoreSavedNodeEnv() {
636
651
}
637
652
638
653
function runConsoleTests ( defaultReporter : string , runInParallel : boolean , done : ( e ?: any ) => void ) {
639
- const lintFlag = cmdLineOptions [ " lint" ] ;
654
+ const lintFlag = cmdLineOptions . lint ;
640
655
cleanTestDirs ( ( err ) => {
641
656
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 ;
648
663
const testConfigFile = "test.config" ;
649
664
if ( fs . existsSync ( testConfigFile ) ) {
650
665
fs . unlinkSync ( testConfigFile ) ;
@@ -660,7 +675,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
660
675
} while ( fs . existsSync ( taskConfigsFolder ) ) ;
661
676
fs . mkdirSync ( taskConfigsFolder ) ;
662
677
663
- workerCount = cmdLineOptions [ " workers" ] ;
678
+ workerCount = cmdLineOptions . workers ;
664
679
}
665
680
666
681
if ( tests || light || taskConfigsFolder ) {
@@ -671,8 +686,8 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
671
686
testTimeout = 400000 ;
672
687
}
673
688
674
- const colors = cmdLineOptions [ " colors" ] ;
675
- const reporter = cmdLineOptions [ " reporter" ] || defaultReporter ;
689
+ const colors = cmdLineOptions . colors ;
690
+ const reporter = cmdLineOptions . reporter || defaultReporter ;
676
691
677
692
// timeout normally isn"t necessary but Travis-CI has been timing out on compiler baselines occasionally
678
693
// 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) {
860
875
861
876
// used to pass data from jake command line directly to run.js
862
877
function 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 } ) ;
864
879
console . log ( "Running tests with config: " + testConfigContents ) ;
865
880
fs . writeFileSync ( "test.config" , testConfigContents ) ;
866
881
}
@@ -870,8 +885,8 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
870
885
cleanTestDirs ( ( err ) => {
871
886
if ( err ) { console . error ( err ) ; done ( err ) ; process . exit ( 1 ) ; }
872
887
host = "node" ;
873
- const tests = cmdLineOptions [ " tests" ] ;
874
- const light = cmdLineOptions [ " light" ] ;
888
+ const tests = cmdLineOptions . tests ;
889
+ const light = cmdLineOptions . light ;
875
890
const testConfigFile = "test.config" ;
876
891
if ( fs . existsSync ( testConfigFile ) ) {
877
892
fs . unlinkSync ( testConfigFile ) ;
@@ -881,8 +896,8 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
881
896
}
882
897
883
898
const args = [ nodeServerOutFile ] ;
884
- if ( cmdLineOptions [ " browser" ] ) {
885
- args . push ( cmdLineOptions [ " browser" ] ) ;
899
+ if ( cmdLineOptions . browser ) {
900
+ args . push ( cmdLineOptions . browser ) ;
886
901
}
887
902
if ( tests ) {
888
903
args . push ( JSON . stringify ( tests ) ) ;
@@ -892,13 +907,13 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
892
907
} ) ;
893
908
894
909
gulp . task ( "generate-code-coverage" , "Generates code coverage data via istanbul" , [ "tests" ] , ( done ) => {
895
- const testTimeout = cmdLineOptions [ " timeout" ] ;
910
+ const testTimeout = cmdLineOptions . timeout ;
896
911
exec ( "istanbul" , [ "cover" , "node_modules/mocha/bin/_mocha" , "--" , "-R" , "min" , "-t" , testTimeout . toString ( ) , run ] , done , done ) ;
897
912
} ) ;
898
913
899
914
900
915
function getDiffTool ( ) {
901
- const program = process . env [ " DIFF" ] ;
916
+ const program = process . env . DIFF ;
902
917
if ( ! program ) {
903
918
console . error ( "Add the 'DIFF' environment variable to the path of the program you want to use." ) ;
904
919
process . exit ( 1 ) ;
@@ -1019,7 +1034,7 @@ gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => {
1019
1034
} ) ;
1020
1035
1021
1036
gulp . 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" ;
1023
1038
exec ( host , [ instrumenterJsPath , "record" , test , builtLocalCompiler ] , done , done ) ;
1024
1039
} ) ;
1025
1040
@@ -1088,7 +1103,7 @@ function spawnLintWorker(files: {path: string}[], callback: (failures: number) =
1088
1103
1089
1104
gulp . task ( "lint" , "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex" , [ "build-rules" ] , ( ) => {
1090
1105
if ( fold . isTravis ( ) ) console . log ( fold . start ( "lint" ) ) ;
1091
- const fileMatcher = cmdLineOptions [ " files" ] ;
1106
+ const fileMatcher = cmdLineOptions . files ;
1092
1107
const files = fileMatcher
1093
1108
? `src/**/${ fileMatcher } `
1094
1109
: "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