@@ -46,14 +46,15 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
4646 boolean : [ "debug" , "inspect" , "light" , "colors" , "lint" , "soft" ] ,
4747 string : [ "browser" , "tests" , "host" , "reporter" , "stackTraceLimit" , "timeout" ] ,
4848 alias : {
49- b : "browser" ,
50- d : "debug" , "debug-brk" : "debug" ,
51- i : "inspect" , "inspect-brk" : "inspect" ,
52- t : "tests" , test : "tests" ,
53- r : "reporter" ,
54- c : "colors" , color : "colors" ,
55- f : "files" , file : "files" ,
56- w : "workers" ,
49+ "b" : "browser" ,
50+ "d" : "debug" , "debug-brk" : "debug" ,
51+ "i" : "inspect" , "inspect-brk" : "inspect" ,
52+ "t" : "tests" , "test" : "tests" ,
53+ "ru" : "runners" , "runner" : "runners" ,
54+ "r" : "reporter" ,
55+ "c" : "colors" , "color" : "colors" ,
56+ "f" : "files" , "file" : "files" ,
57+ "w" : "workers" ,
5758 } ,
5859 default : {
5960 soft : false ,
@@ -64,6 +65,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
6465 browser : process . env . browser || process . env . b || "IE" ,
6566 timeout : process . env . timeout || 40000 ,
6667 tests : process . env . test || process . env . tests || process . env . t ,
68+ runners : process . env . runners || process . env . runner || process . env . ru ,
6769 light : process . env . light === undefined || process . env . light !== "false" ,
6870 reporter : process . env . reporter || process . env . r ,
6971 lint : process . env . lint || true ,
@@ -72,7 +74,8 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
7274 }
7375} ) ;
7476
75- function exec ( cmd : string , args : string [ ] , complete : ( ) => void = ( ( ) => { } ) , error : ( e : any , status : number ) => void = ( ( ) => { } ) ) {
77+ const noop = ( ) => { } ; // tslint:disable-line no-empty
78+ function exec ( cmd : string , args : string [ ] , complete : ( ) => void = noop , error : ( e : any , status : number ) => void = noop ) {
7679 console . log ( `${ cmd } ${ args . join ( " " ) } ` ) ;
7780 // TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
7881 const subshellFlag = isWin ? "/c" : "-c" ;
@@ -99,12 +102,12 @@ const lclDirectory = "src/loc/lcl";
99102
100103const builtDirectory = "built/" ;
101104const builtLocalDirectory = "built/local/" ;
102- const LKGDirectory = "lib/" ;
105+ const lkgDirectory = "lib/" ;
103106
104107const copyright = "CopyrightNotice.txt" ;
105108
106109const compilerFilename = "tsc.js" ;
107- const LKGCompiler = path . join ( LKGDirectory , compilerFilename ) ;
110+ const lkgCompiler = path . join ( lkgDirectory , compilerFilename ) ;
108111const builtLocalCompiler = path . join ( builtLocalDirectory , compilerFilename ) ;
109112
110113const nodeModulesPathPrefix = path . resolve ( "./node_modules/.bin/" ) ;
@@ -123,34 +126,31 @@ const es2015LibrarySources = [
123126 "es2015.symbol.wellknown.d.ts"
124127] ;
125128
126- const es2015LibrarySourceMap = es2015LibrarySources . map ( function ( source ) {
127- return { target : "lib." + source , sources : [ "header.d.ts" , source ] } ;
128- } ) ;
129+ const es2015LibrarySourceMap = es2015LibrarySources . map ( source =>
130+ ( { target : "lib." + source , sources : [ "header.d.ts" , source ] } ) ) ;
129131
130132const es2016LibrarySource = [ "es2016.array.include.d.ts" ] ;
131133
132- const es2016LibrarySourceMap = es2016LibrarySource . map ( function ( source ) {
133- return { target : "lib." + source , sources : [ "header.d.ts" , source ] } ;
134- } ) ;
134+ const es2016LibrarySourceMap = es2016LibrarySource . map ( source =>
135+ ( { target : "lib." + source , sources : [ "header.d.ts" , source ] } ) ) ;
135136
136137const es2017LibrarySource = [
137138 "es2017.object.d.ts" ,
138139 "es2017.sharedmemory.d.ts" ,
139140 "es2017.string.d.ts" ,
140141 "es2017.intl.d.ts" ,
142+ "es2017.typedarrays.d.ts" ,
141143] ;
142144
143- const es2017LibrarySourceMap = es2017LibrarySource . map ( function ( source ) {
144- return { target : "lib." + source , sources : [ "header.d.ts" , source ] } ;
145- } ) ;
145+ const es2017LibrarySourceMap = es2017LibrarySource . map ( source =>
146+ ( { target : "lib." + source , sources : [ "header.d.ts" , source ] } ) ) ;
146147
147148const esnextLibrarySource = [
148149 "esnext.asynciterable.d.ts"
149150] ;
150151
151- const esnextLibrarySourceMap = esnextLibrarySource . map ( function ( source ) {
152- return { target : "lib." + source , sources : [ "header.d.ts" , source ] } ;
153- } ) ;
152+ const esnextLibrarySourceMap = esnextLibrarySource . map ( source =>
153+ ( { target : "lib." + source , sources : [ "header.d.ts" , source ] } ) ) ;
154154
155155const hostsLibrarySources = [ "dom.generated.d.ts" , "webworker.importscripts.d.ts" , "scripthost.d.ts" ] ;
156156
@@ -171,14 +171,13 @@ 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
179- const libraryTargets = librarySourceMap . map ( function ( f ) {
180- return path . join ( builtLocalDirectory , f . target ) ;
181- } ) ;
179+ const libraryTargets = librarySourceMap . map ( f =>
180+ path . join ( builtLocalDirectory , f . target ) ) ;
182181
183182/**
184183 * .lcg file is what localization team uses to know what messages to localize.
@@ -193,22 +192,19 @@ const generatedLCGFile = path.join(builtLocalDirectory, "enu", "diagnosticMessag
193192 * 2. 'src\compiler\diagnosticMessages.generated.json' => 'built\local\ENU\diagnosticMessages.generated.json.lcg'
194193 * generate the lcg file (source of messages to localize) from the diagnosticMessages.generated.json
195194 */
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 ) ;
195+ const localizationTargets = [ "cs" , "de" , "es" , "fr" , "it" , "ja" , "ko" , "pl" , "pt-BR" , "ru" , "tr" , "zh-CN" , "zh-TW" ]
196+ . map ( f => path . join ( builtLocalDirectory , f , "diagnosticMessages.generated.json" ) )
197+ . concat ( generatedLCGFile ) ;
199198
200199for ( const i in libraryTargets ) {
201200 const entry = librarySourceMap [ i ] ;
202201 const target = libraryTargets [ i ] ;
203- const sources = [ copyright ] . concat ( entry . sources . map ( function ( s ) {
204- return path . join ( libraryDirectory , s ) ;
205- } ) ) ;
206- gulp . task ( target , /*help*/ false , [ ] , function ( ) {
207- return gulp . src ( sources )
202+ const sources = [ copyright ] . concat ( entry . sources . map ( s => path . join ( libraryDirectory , s ) ) ) ;
203+ gulp . task ( target , /*help*/ false , [ ] , ( ) =>
204+ gulp . src ( sources )
208205 . pipe ( newer ( target ) )
209206 . pipe ( concat ( target , { newLine : "\n\n" } ) )
210- . pipe ( gulp . dest ( "." ) ) ;
211- } ) ;
207+ . pipe ( gulp . dest ( "." ) ) ) ;
212208}
213209
214210const configureNightlyJs = path . join ( scriptsDirectory , "configureNightly.js" ) ;
@@ -575,9 +571,7 @@ gulp.task(specMd, /*help*/ false, [word2mdJs], (done) => {
575571 const specMDFullPath = path . resolve ( specMd ) ;
576572 const cmd = "cscript //nologo " + word2mdJs + " \"" + specWordFullPath + "\" " + "\"" + specMDFullPath + "\"" ;
577573 console . log ( cmd ) ;
578- cp . exec ( cmd , function ( ) {
579- done ( ) ;
580- } ) ;
574+ cp . exec ( cmd , done ) ;
581575} ) ;
582576
583577gulp . task ( "generate-spec" , "Generates a Markdown version of the Language Specification" , [ specMd ] ) ;
@@ -599,7 +593,7 @@ gulp.task("VerifyLKG", /*help*/ false, [], () => {
599593 ". The following files are missing:\n" + missingFiles . join ( "\n" ) ) ;
600594 }
601595 // Copy all the targets into the LKG directory
602- return gulp . src ( [ ...expectedFiles , path . join ( builtLocalDirectory , "**" ) , `!${ path . join ( builtLocalDirectory , "tslint" ) } ` , `!${ path . join ( builtLocalDirectory , "*.*" ) } ` ] ) . pipe ( gulp . dest ( LKGDirectory ) ) ;
596+ return gulp . src ( [ ...expectedFiles , path . join ( builtLocalDirectory , "**" ) , `!${ path . join ( builtLocalDirectory , "tslint" ) } ` , `!${ path . join ( builtLocalDirectory , "*.*" ) } ` ] ) . pipe ( gulp . dest ( lkgDirectory ) ) ;
603597} ) ;
604598
605599gulp . task ( "LKGInternal" , /*help*/ false , [ "lib" , "local" ] ) ;
@@ -658,6 +652,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
658652 const debug = cmdLineOptions . debug ;
659653 const inspect = cmdLineOptions . inspect ;
660654 const tests = cmdLineOptions . tests ;
655+ const runners = cmdLineOptions . runners ;
661656 const light = cmdLineOptions . light ;
662657 const stackTraceLimit = cmdLineOptions . stackTraceLimit ;
663658 const testConfigFile = "test.config" ;
@@ -678,8 +673,8 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
678673 workerCount = cmdLineOptions . workers ;
679674 }
680675
681- if ( tests || light || taskConfigsFolder ) {
682- writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount , stackTraceLimit ) ;
676+ if ( tests || runners || light || taskConfigsFolder ) {
677+ writeTestConfigFile ( tests , runners , light , taskConfigsFolder , workerCount , stackTraceLimit ) ;
683678 }
684679
685680 if ( tests && tests . toLocaleLowerCase ( ) === "rwc" ) {
@@ -714,17 +709,13 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
714709 }
715710 args . push ( run ) ;
716711 setNodeEnvToDevelopment ( ) ;
717- exec ( mocha , args , lintThenFinish , function ( e , status ) {
718- finish ( e , status ) ;
719- } ) ;
712+ exec ( mocha , args , lintThenFinish , finish ) ;
720713
721714 }
722715 else {
723716 // run task to load all tests and partition them between workers
724717 setNodeEnvToDevelopment ( ) ;
725- exec ( host , [ run ] , lintThenFinish , function ( e , status ) {
726- finish ( e , status ) ;
727- } ) ;
718+ exec ( host , [ run ] , lintThenFinish , finish ) ;
728719 }
729720 } ) ;
730721
@@ -874,8 +865,8 @@ function cleanTestDirs(done: (e?: any) => void) {
874865}
875866
876867// used to pass data from jake command line directly to run.js
877- function writeTestConfigFile ( tests : string , light : boolean , taskConfigsFolder ?: string , workerCount ?: number , stackTraceLimit ?: string ) {
878- const testConfigContents = JSON . stringify ( { test : tests ? [ tests ] : undefined , light, workerCount, stackTraceLimit, taskConfigsFolder, noColor : ! cmdLineOptions . colors } ) ;
868+ function writeTestConfigFile ( tests : string , runners : string , light : boolean , taskConfigsFolder ?: string , workerCount ?: number , stackTraceLimit ?: string ) {
869+ const testConfigContents = JSON . stringify ( { test : tests ? [ tests ] : undefined , runner : runners ? runners . split ( "," ) : undefined , light, workerCount, stackTraceLimit, taskConfigsFolder, noColor : ! cmdLineOptions . colors } ) ;
879870 console . log ( "Running tests with config: " + testConfigContents ) ;
880871 fs . writeFileSync ( "test.config" , testConfigContents ) ;
881872}
@@ -886,13 +877,14 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
886877 if ( err ) { console . error ( err ) ; done ( err ) ; process . exit ( 1 ) ; }
887878 host = "node" ;
888879 const tests = cmdLineOptions . tests ;
880+ const runners = cmdLineOptions . runners ;
889881 const light = cmdLineOptions . light ;
890882 const testConfigFile = "test.config" ;
891883 if ( fs . existsSync ( testConfigFile ) ) {
892884 fs . unlinkSync ( testConfigFile ) ;
893885 }
894- if ( tests || light ) {
895- writeTestConfigFile ( tests , light ) ;
886+ if ( tests || runners || light ) {
887+ writeTestConfigFile ( tests , runners , light ) ;
896888 }
897889
898890 const args = [ nodeServerOutFile ] ;
@@ -1006,7 +998,7 @@ gulp.task(loggedIOJsPath, /*help*/ false, [], (done) => {
1006998 const temp = path . join ( builtLocalDirectory , "temp" ) ;
1007999 mkdirP ( temp , ( err ) => {
10081000 if ( err ) { console . error ( err ) ; done ( err ) ; process . exit ( 1 ) ; }
1009- exec ( host , [ LKGCompiler , "--types" , "--target es5" , "--lib es5" , "--outdir" , temp , loggedIOpath ] , ( ) => {
1001+ exec ( host , [ lkgCompiler , "--types" , "--target es5" , "--lib es5" , "--outdir" , temp , loggedIOpath ] , ( ) => {
10101002 fs . renameSync ( path . join ( temp , "/harness/loggedIO.js" ) , loggedIOJsPath ) ;
10111003 del ( temp ) . then ( ( ) => done ( ) , done ) ;
10121004 } , done ) ;
@@ -1043,7 +1035,7 @@ gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", s
10431035} ) ;
10441036
10451037gulp . task ( "build-rules" , "Compiles tslint rules to js" , ( ) => {
1046- const settings : tsc . Settings = getCompilerSettings ( { module : "commonjs" , " lib" : [ "es6" ] } , /*useBuiltCompiler*/ false ) ;
1038+ const settings : tsc . Settings = getCompilerSettings ( { module : "commonjs" , lib : [ "es6" ] } , /*useBuiltCompiler*/ false ) ;
10471039 const dest = path . join ( builtLocalDirectory , "tslint" ) ;
10481040 return gulp . src ( "scripts/tslint/**/*.ts" )
10491041 . pipe ( newer ( {
@@ -1082,7 +1074,7 @@ function sendNextFile(files: {path: string}[], child: cp.ChildProcess, callback:
10821074function spawnLintWorker ( files : { path : string } [ ] , callback : ( failures : number ) => void ) {
10831075 const child = cp . fork ( "./scripts/parallel-lint" ) ;
10841076 let failures = 0 ;
1085- child . on ( "message" , function ( data ) {
1077+ child . on ( "message" , data => {
10861078 switch ( data . kind ) {
10871079 case "result" :
10881080 if ( data . failures > 0 ) {
@@ -1106,7 +1098,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
11061098 const fileMatcher = cmdLineOptions . files ;
11071099 const files = fileMatcher
11081100 ? `src/**/${ fileMatcher } `
1109- : "Gulpfile.ts 'scripts/generateLocalizedDiagnosticMessages.ts' 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated .d.ts'" ;
1101+ : "Gulpfile.ts 'scripts/generateLocalizedDiagnosticMessages.ts' 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude 'src/lib/*.d.ts'" ;
11101102 const cmd = `node node_modules/tslint/bin/tslint ${ files } --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish` ;
11111103 console . log ( "Linting: " + cmd ) ;
11121104 child_process . execSync ( cmd , { stdio : [ 0 , 1 , 2 ] } ) ;
0 commit comments