@@ -46,14 +46,15 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
46
46
boolean : [ "debug" , "inspect" , "light" , "colors" , "lint" , "soft" ] ,
47
47
string : [ "browser" , "tests" , "host" , "reporter" , "stackTraceLimit" , "timeout" ] ,
48
48
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" ,
57
58
} ,
58
59
default : {
59
60
soft : false ,
@@ -64,6 +65,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
64
65
browser : process . env . browser || process . env . b || "IE" ,
65
66
timeout : process . env . timeout || 40000 ,
66
67
tests : process . env . test || process . env . tests || process . env . t ,
68
+ runners : process . env . runners || process . env . runner || process . env . ru ,
67
69
light : process . env . light === undefined || process . env . light !== "false" ,
68
70
reporter : process . env . reporter || process . env . r ,
69
71
lint : process . env . lint || true ,
@@ -72,7 +74,8 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
72
74
}
73
75
} ) ;
74
76
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 ) {
76
79
console . log ( `${ cmd } ${ args . join ( " " ) } ` ) ;
77
80
// TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
78
81
const subshellFlag = isWin ? "/c" : "-c" ;
@@ -99,12 +102,12 @@ const lclDirectory = "src/loc/lcl";
99
102
100
103
const builtDirectory = "built/" ;
101
104
const builtLocalDirectory = "built/local/" ;
102
- const LKGDirectory = "lib/" ;
105
+ const lkgDirectory = "lib/" ;
103
106
104
107
const copyright = "CopyrightNotice.txt" ;
105
108
106
109
const compilerFilename = "tsc.js" ;
107
- const LKGCompiler = path . join ( LKGDirectory , compilerFilename ) ;
110
+ const lkgCompiler = path . join ( lkgDirectory , compilerFilename ) ;
108
111
const builtLocalCompiler = path . join ( builtLocalDirectory , compilerFilename ) ;
109
112
110
113
const nodeModulesPathPrefix = path . resolve ( "./node_modules/.bin/" ) ;
@@ -123,34 +126,31 @@ const es2015LibrarySources = [
123
126
"es2015.symbol.wellknown.d.ts"
124
127
] ;
125
128
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 ] } ) ) ;
129
131
130
132
const es2016LibrarySource = [ "es2016.array.include.d.ts" ] ;
131
133
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 ] } ) ) ;
135
136
136
137
const es2017LibrarySource = [
137
138
"es2017.object.d.ts" ,
138
139
"es2017.sharedmemory.d.ts" ,
139
140
"es2017.string.d.ts" ,
140
141
"es2017.intl.d.ts" ,
142
+ "es2017.typedarrays.d.ts" ,
141
143
] ;
142
144
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 ] } ) ) ;
146
147
147
148
const esnextLibrarySource = [
148
149
"esnext.asynciterable.d.ts"
149
150
] ;
150
151
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 ] } ) ) ;
154
154
155
155
const hostsLibrarySources = [ "dom.generated.d.ts" , "webworker.importscripts.d.ts" , "scripthost.d.ts" ] ;
156
156
@@ -171,14 +171,13 @@ 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
- 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 ) ) ;
182
181
183
182
/**
184
183
* .lcg file is what localization team uses to know what messages to localize.
@@ -193,22 +192,19 @@ const generatedLCGFile = path.join(builtLocalDirectory, "enu", "diagnosticMessag
193
192
* 2. 'src\compiler\diagnosticMessages.generated.json' => 'built\local\ENU\diagnosticMessages.generated.json.lcg'
194
193
* generate the lcg file (source of messages to localize) from the diagnosticMessages.generated.json
195
194
*/
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 ) ;
199
198
200
199
for ( const i in libraryTargets ) {
201
200
const entry = librarySourceMap [ i ] ;
202
201
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 )
208
205
. pipe ( newer ( target ) )
209
206
. pipe ( concat ( target , { newLine : "\n\n" } ) )
210
- . pipe ( gulp . dest ( "." ) ) ;
211
- } ) ;
207
+ . pipe ( gulp . dest ( "." ) ) ) ;
212
208
}
213
209
214
210
const configureNightlyJs = path . join ( scriptsDirectory , "configureNightly.js" ) ;
@@ -575,9 +571,7 @@ gulp.task(specMd, /*help*/ false, [word2mdJs], (done) => {
575
571
const specMDFullPath = path . resolve ( specMd ) ;
576
572
const cmd = "cscript //nologo " + word2mdJs + " \"" + specWordFullPath + "\" " + "\"" + specMDFullPath + "\"" ;
577
573
console . log ( cmd ) ;
578
- cp . exec ( cmd , function ( ) {
579
- done ( ) ;
580
- } ) ;
574
+ cp . exec ( cmd , done ) ;
581
575
} ) ;
582
576
583
577
gulp . task ( "generate-spec" , "Generates a Markdown version of the Language Specification" , [ specMd ] ) ;
@@ -599,7 +593,7 @@ gulp.task("VerifyLKG", /*help*/ false, [], () => {
599
593
". The following files are missing:\n" + missingFiles . join ( "\n" ) ) ;
600
594
}
601
595
// 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 ) ) ;
603
597
} ) ;
604
598
605
599
gulp . task ( "LKGInternal" , /*help*/ false , [ "lib" , "local" ] ) ;
@@ -658,6 +652,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
658
652
const debug = cmdLineOptions . debug ;
659
653
const inspect = cmdLineOptions . inspect ;
660
654
const tests = cmdLineOptions . tests ;
655
+ const runners = cmdLineOptions . runners ;
661
656
const light = cmdLineOptions . light ;
662
657
const stackTraceLimit = cmdLineOptions . stackTraceLimit ;
663
658
const testConfigFile = "test.config" ;
@@ -678,8 +673,8 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
678
673
workerCount = cmdLineOptions . workers ;
679
674
}
680
675
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 ) ;
683
678
}
684
679
685
680
if ( tests && tests . toLocaleLowerCase ( ) === "rwc" ) {
@@ -714,17 +709,13 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
714
709
}
715
710
args . push ( run ) ;
716
711
setNodeEnvToDevelopment ( ) ;
717
- exec ( mocha , args , lintThenFinish , function ( e , status ) {
718
- finish ( e , status ) ;
719
- } ) ;
712
+ exec ( mocha , args , lintThenFinish , finish ) ;
720
713
721
714
}
722
715
else {
723
716
// run task to load all tests and partition them between workers
724
717
setNodeEnvToDevelopment ( ) ;
725
- exec ( host , [ run ] , lintThenFinish , function ( e , status ) {
726
- finish ( e , status ) ;
727
- } ) ;
718
+ exec ( host , [ run ] , lintThenFinish , finish ) ;
728
719
}
729
720
} ) ;
730
721
@@ -874,8 +865,8 @@ function cleanTestDirs(done: (e?: any) => void) {
874
865
}
875
866
876
867
// 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 } ) ;
879
870
console . log ( "Running tests with config: " + testConfigContents ) ;
880
871
fs . writeFileSync ( "test.config" , testConfigContents ) ;
881
872
}
@@ -886,13 +877,14 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
886
877
if ( err ) { console . error ( err ) ; done ( err ) ; process . exit ( 1 ) ; }
887
878
host = "node" ;
888
879
const tests = cmdLineOptions . tests ;
880
+ const runners = cmdLineOptions . runners ;
889
881
const light = cmdLineOptions . light ;
890
882
const testConfigFile = "test.config" ;
891
883
if ( fs . existsSync ( testConfigFile ) ) {
892
884
fs . unlinkSync ( testConfigFile ) ;
893
885
}
894
- if ( tests || light ) {
895
- writeTestConfigFile ( tests , light ) ;
886
+ if ( tests || runners || light ) {
887
+ writeTestConfigFile ( tests , runners , light ) ;
896
888
}
897
889
898
890
const args = [ nodeServerOutFile ] ;
@@ -1006,7 +998,7 @@ gulp.task(loggedIOJsPath, /*help*/ false, [], (done) => {
1006
998
const temp = path . join ( builtLocalDirectory , "temp" ) ;
1007
999
mkdirP ( temp , ( err ) => {
1008
1000
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 ] , ( ) => {
1010
1002
fs . renameSync ( path . join ( temp , "/harness/loggedIO.js" ) , loggedIOJsPath ) ;
1011
1003
del ( temp ) . then ( ( ) => done ( ) , done ) ;
1012
1004
} , done ) ;
@@ -1043,7 +1035,7 @@ gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", s
1043
1035
} ) ;
1044
1036
1045
1037
gulp . 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 ) ;
1047
1039
const dest = path . join ( builtLocalDirectory , "tslint" ) ;
1048
1040
return gulp . src ( "scripts/tslint/**/*.ts" )
1049
1041
. pipe ( newer ( {
@@ -1082,7 +1074,7 @@ function sendNextFile(files: {path: string}[], child: cp.ChildProcess, callback:
1082
1074
function spawnLintWorker ( files : { path : string } [ ] , callback : ( failures : number ) => void ) {
1083
1075
const child = cp . fork ( "./scripts/parallel-lint" ) ;
1084
1076
let failures = 0 ;
1085
- child . on ( "message" , function ( data ) {
1077
+ child . on ( "message" , data => {
1086
1078
switch ( data . kind ) {
1087
1079
case "result" :
1088
1080
if ( data . failures > 0 ) {
@@ -1106,7 +1098,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
1106
1098
const fileMatcher = cmdLineOptions . files ;
1107
1099
const files = fileMatcher
1108
1100
? `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'" ;
1110
1102
const cmd = `node node_modules/tslint/bin/tslint ${ files } --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish` ;
1111
1103
console . log ( "Linting: " + cmd ) ;
1112
1104
child_process . execSync ( cmd , { stdio : [ 0 , 1 , 2 ] } ) ;
0 commit comments