@@ -17,7 +17,6 @@ declare module "gulp-typescript" {
17
17
stripInternal ?: boolean ;
18
18
types ?: string [ ] ;
19
19
}
20
- interface CompileStream extends NodeJS . ReadWriteStream { } // Either gulp or gulp-typescript has some odd typings which don't reflect reality, making this required
21
20
}
22
21
import * as insert from "gulp-insert" ;
23
22
import * as sourcemaps from "gulp-sourcemaps" ;
@@ -39,9 +38,11 @@ const gulp = helpMaker(originalGulp);
39
38
const mochaParallel = require ( "./scripts/mocha-parallel.js" ) ;
40
39
const { runTestsInParallel} = mochaParallel ;
41
40
41
+ Error . stackTraceLimit = 1000 ;
42
+
42
43
const cmdLineOptions = minimist ( process . argv . slice ( 2 ) , {
43
44
boolean : [ "debug" , "light" , "colors" , "lint" , "soft" ] ,
44
- string : [ "browser" , "tests" , "host" , "reporter" ] ,
45
+ string : [ "browser" , "tests" , "host" , "reporter" , "stackTraceLimit" ] ,
45
46
alias : {
46
47
d : "debug" ,
47
48
t : "tests" ,
@@ -167,7 +168,7 @@ for (const i in libraryTargets) {
167
168
gulp . task ( target , false , [ ] , function ( ) {
168
169
return gulp . src ( sources )
169
170
. pipe ( newer ( target ) )
170
- . pipe ( concat ( target , { newLine : "" } ) )
171
+ . pipe ( concat ( target , { newLine : "\n\n " } ) )
171
172
. pipe ( gulp . dest ( "." ) ) ;
172
173
} ) ;
173
174
}
@@ -378,18 +379,18 @@ gulp.task(builtLocalCompiler, false, [servicesFile], () => {
378
379
return localCompilerProject . src ( )
379
380
. pipe ( newer ( builtLocalCompiler ) )
380
381
. pipe ( sourcemaps . init ( ) )
381
- . pipe ( tsc ( localCompilerProject ) )
382
+ . pipe ( localCompilerProject ( ) )
382
383
. pipe ( prependCopyright ( ) )
383
384
. pipe ( sourcemaps . write ( "." ) )
384
- . pipe ( gulp . dest ( builtLocalDirectory ) ) ;
385
+ . pipe ( gulp . dest ( "." ) ) ;
385
386
} ) ;
386
387
387
388
gulp . task ( servicesFile , false , [ "lib" , "generate-diagnostics" ] , ( ) => {
388
389
const servicesProject = tsc . createProject ( "src/services/tsconfig.json" , getCompilerSettings ( { removeComments : false } , /*useBuiltCompiler*/ false ) ) ;
389
390
const { js, dts} = servicesProject . src ( )
390
391
. pipe ( newer ( servicesFile ) )
391
392
. pipe ( sourcemaps . init ( ) )
392
- . pipe ( tsc ( servicesProject ) ) ;
393
+ . pipe ( servicesProject ( ) ) ;
393
394
const completedJs = js . pipe ( prependCopyright ( ) )
394
395
. pipe ( sourcemaps . write ( "." ) ) ;
395
396
const completedDts = dts . pipe ( prependCopyright ( /*outputCopyright*/ true ) )
@@ -407,26 +408,52 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
407
408
file . path = nodeDefinitionsFile ;
408
409
return content + "\r\nexport = ts;" ;
409
410
} ) )
410
- . pipe ( gulp . dest ( builtLocalDirectory ) ) ,
411
+ . pipe ( gulp . dest ( "." ) ) ,
411
412
completedDts . pipe ( clone ( ) )
412
413
. pipe ( insert . transform ( ( content , file ) => {
413
414
file . path = nodeStandaloneDefinitionsFile ;
414
415
return content . replace ( / d e c l a r e ( n a m e s p a c e | m o d u l e ) t s / g, 'declare module "typescript"' ) ;
415
416
} ) )
416
- ] ) . pipe ( gulp . dest ( builtLocalDirectory ) ) ;
417
+ ] ) . pipe ( gulp . dest ( "." ) ) ;
418
+ } ) ;
419
+
420
+ // cancellationToken.js
421
+ const cancellationTokenJs = path . join ( builtLocalDirectory , "cancellationToken.js" ) ;
422
+ gulp . task ( cancellationTokenJs , false , [ servicesFile ] , ( ) => {
423
+ const cancellationTokenProject = tsc . createProject ( "src/server/cancellationToken/tsconfig.json" , getCompilerSettings ( { } , /*useBuiltCompiler*/ true ) ) ;
424
+ return cancellationTokenProject . src ( )
425
+ . pipe ( newer ( cancellationTokenJs ) )
426
+ . pipe ( sourcemaps . init ( ) )
427
+ . pipe ( cancellationTokenProject ( ) )
428
+ . pipe ( prependCopyright ( ) )
429
+ . pipe ( sourcemaps . write ( "." ) )
430
+ . pipe ( gulp . dest ( builtLocalDirectory ) ) ;
431
+ } ) ;
432
+
433
+ // typingsInstallerFile.js
434
+ const typingsInstallerJs = path . join ( builtLocalDirectory , "typingsInstaller.js" ) ;
435
+ gulp . task ( typingsInstallerJs , false , [ servicesFile ] , ( ) => {
436
+ const cancellationTokenProject = tsc . createProject ( "src/server/typingsInstaller/tsconfig.json" , getCompilerSettings ( { } , /*useBuiltCompiler*/ true ) ) ;
437
+ return cancellationTokenProject . src ( )
438
+ . pipe ( newer ( typingsInstallerJs ) )
439
+ . pipe ( sourcemaps . init ( ) )
440
+ . pipe ( cancellationTokenProject ( ) )
441
+ . pipe ( prependCopyright ( ) )
442
+ . pipe ( sourcemaps . write ( "." ) )
443
+ . pipe ( gulp . dest ( "." ) ) ;
417
444
} ) ;
418
445
419
446
const serverFile = path . join ( builtLocalDirectory , "tsserver.js" ) ;
420
447
421
- gulp . task ( serverFile , false , [ servicesFile ] , ( ) => {
448
+ gulp . task ( serverFile , false , [ servicesFile , typingsInstallerJs , cancellationTokenJs ] , ( ) => {
422
449
const serverProject = tsc . createProject ( "src/server/tsconfig.json" , getCompilerSettings ( { } , /*useBuiltCompiler*/ true ) ) ;
423
450
return serverProject . src ( )
424
451
. pipe ( newer ( serverFile ) )
425
452
. pipe ( sourcemaps . init ( ) )
426
- . pipe ( tsc ( serverProject ) )
453
+ . pipe ( serverProject ( ) )
427
454
. pipe ( prependCopyright ( ) )
428
455
. pipe ( sourcemaps . write ( "." ) )
429
- . pipe ( gulp . dest ( builtLocalDirectory ) ) ;
456
+ . pipe ( gulp . dest ( "." ) ) ;
430
457
} ) ;
431
458
432
459
const tsserverLibraryFile = path . join ( builtLocalDirectory , "tsserverlibrary.js" ) ;
@@ -437,22 +464,21 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
437
464
const { js, dts} : { js : NodeJS . ReadableStream , dts : NodeJS . ReadableStream } = serverLibraryProject . src ( )
438
465
. pipe ( sourcemaps . init ( ) )
439
466
. pipe ( newer ( tsserverLibraryFile ) )
440
- . pipe ( tsc ( serverLibraryProject ) ) ;
467
+ . pipe ( serverLibraryProject ( ) ) ;
441
468
442
469
return merge2 ( [
443
470
js . pipe ( prependCopyright ( ) )
444
471
. pipe ( sourcemaps . write ( "." ) )
445
- . pipe ( gulp . dest ( builtLocalDirectory ) ) ,
472
+ . pipe ( gulp . dest ( "." ) ) ,
446
473
dts . pipe ( prependCopyright ( ) )
447
- . pipe ( gulp . dest ( builtLocalDirectory ) )
474
+ . pipe ( gulp . dest ( "." ) )
448
475
] ) ;
449
476
} ) ;
450
477
451
478
gulp . task ( "lssl" , "Builds language service server library" , [ tsserverLibraryFile ] ) ;
452
479
gulp . task ( "local" , "Builds the full compiler and services" , [ builtLocalCompiler , servicesFile , serverFile , builtGeneratedDiagnosticMessagesJSON , tsserverLibraryFile ] ) ;
453
480
gulp . task ( "tsc" , "Builds only the compiler" , [ builtLocalCompiler ] ) ;
454
481
455
-
456
482
// Generate Markdown spec
457
483
const word2mdJs = path . join ( scriptsDirectory , "word2md.js" ) ;
458
484
const word2mdTs = path . join ( scriptsDirectory , "word2md.ts" ) ;
@@ -491,7 +517,7 @@ gulp.task("useDebugMode", false, [], (done) => { useDebugMode = true; done(); })
491
517
gulp . task ( "dontUseDebugMode" , false , [ ] , ( done ) => { useDebugMode = false ; done ( ) ; } ) ;
492
518
493
519
gulp . task ( "VerifyLKG" , false , [ ] , ( ) => {
494
- const expectedFiles = [ builtLocalCompiler , servicesFile , serverFile , nodePackageFile , nodeDefinitionsFile , standaloneDefinitionsFile , tsserverLibraryFile , tsserverLibraryDefinitionFile ] . concat ( libraryTargets ) ;
520
+ const expectedFiles = [ builtLocalCompiler , servicesFile , serverFile , nodePackageFile , nodeDefinitionsFile , standaloneDefinitionsFile , tsserverLibraryFile , tsserverLibraryDefinitionFile , typingsInstallerJs , cancellationTokenJs ] . concat ( libraryTargets ) ;
495
521
const missingFiles = expectedFiles . filter ( function ( f ) {
496
522
return ! fs . existsSync ( f ) ;
497
523
} ) ;
@@ -517,9 +543,9 @@ gulp.task(run, false, [servicesFile], () => {
517
543
return testProject . src ( )
518
544
. pipe ( newer ( run ) )
519
545
. pipe ( sourcemaps . init ( ) )
520
- . pipe ( tsc ( testProject ) )
546
+ . pipe ( testProject ( ) )
521
547
. pipe ( sourcemaps . write ( "." , { includeContent : false , sourceRoot : "../../" } ) )
522
- . pipe ( gulp . dest ( builtLocalDirectory ) ) ;
548
+ . pipe ( gulp . dest ( "." ) ) ;
523
549
} ) ;
524
550
525
551
const internalTests = "internal/" ;
@@ -551,14 +577,15 @@ function restoreSavedNodeEnv() {
551
577
process . env . NODE_ENV = savedNodeEnv ;
552
578
}
553
579
554
- let testTimeout = 20000 ;
580
+ let testTimeout = 40000 ;
555
581
function runConsoleTests ( defaultReporter : string , runInParallel : boolean , done : ( e ?: any ) => void ) {
556
582
const lintFlag = cmdLineOptions [ "lint" ] ;
557
583
cleanTestDirs ( ( err ) => {
558
584
if ( err ) { console . error ( err ) ; failWithStatus ( err , 1 ) ; }
559
585
const debug = cmdLineOptions [ "debug" ] ;
560
586
const tests = cmdLineOptions [ "tests" ] ;
561
587
const light = cmdLineOptions [ "light" ] ;
588
+ const stackTraceLimit = cmdLineOptions [ "stackTraceLimit" ] ;
562
589
const testConfigFile = "test.config" ;
563
590
if ( fs . existsSync ( testConfigFile ) ) {
564
591
fs . unlinkSync ( testConfigFile ) ;
@@ -578,7 +605,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
578
605
}
579
606
580
607
if ( tests || light || taskConfigsFolder ) {
581
- writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount ) ;
608
+ writeTestConfigFile ( tests , light , taskConfigsFolder , workerCount , stackTraceLimit ) ;
582
609
}
583
610
584
611
if ( tests && tests . toLocaleLowerCase ( ) === "rwc" ) {
@@ -698,16 +725,16 @@ declare module "convert-source-map" {
698
725
}
699
726
700
727
gulp . task ( "browserify" , "Runs browserify on run.js to produce a file suitable for running tests in the browser" , [ servicesFile ] , ( done ) => {
701
- const testProject = tsc . createProject ( "src/harness/tsconfig.json" , getCompilerSettings ( { outFile : "built/local/bundle.js" } , /*useBuiltCompiler*/ true ) ) ;
728
+ const testProject = tsc . createProject ( "src/harness/tsconfig.json" , getCompilerSettings ( { outFile : "../../ built/local/bundle.js" } , /*useBuiltCompiler*/ true ) ) ;
702
729
return testProject . src ( )
703
730
. pipe ( newer ( "built/local/bundle.js" ) )
704
731
. pipe ( sourcemaps . init ( ) )
705
- . pipe ( tsc ( testProject ) )
732
+ . pipe ( testProject ( ) )
706
733
. pipe ( through2 . obj ( ( file , enc , next ) => {
707
734
const originalMap = file . sourceMap ;
708
735
const prebundledContent = file . contents . toString ( ) ;
709
736
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
710
- originalMap . sources = originalMap . sources . map ( s => path . resolve ( "src" , s ) ) ;
737
+ originalMap . sources = originalMap . sources . map ( s => path . resolve ( s ) ) ;
711
738
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
712
739
originalMap . file = "built/local/_stream_0.js" ;
713
740
@@ -727,6 +754,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
727
754
sourcemaps : {
728
755
"built/local/_stream_0.js" : originalMap ,
729
756
"built/local/bundle.js" : maps ,
757
+ "node_modules/source-map-support/source-map-support.js" : undefined ,
730
758
}
731
759
} ) ;
732
760
const finalMap = chain . apply ( ) ;
@@ -756,8 +784,8 @@ function cleanTestDirs(done: (e?: any) => void) {
756
784
}
757
785
758
786
// used to pass data from jake command line directly to run.js
759
- function writeTestConfigFile ( tests : string , light : boolean , taskConfigsFolder ?: string , workerCount ?: number ) {
760
- const testConfigContents = JSON . stringify ( { test : tests ? [ tests ] : undefined , light : light , workerCount : workerCount , taskConfigsFolder : taskConfigsFolder } ) ;
787
+ function writeTestConfigFile ( tests : string , light : boolean , taskConfigsFolder ?: string , workerCount ?: number , stackTraceLimit ?: string ) {
788
+ const testConfigContents = JSON . stringify ( { test : tests ? [ tests ] : undefined , light, workerCount, stackTraceLimit , taskConfigsFolder } ) ;
761
789
console . log ( "Running tests with config: " + testConfigContents ) ;
762
790
fs . writeFileSync ( "test.config" , testConfigContents ) ;
763
791
}
@@ -887,7 +915,7 @@ gulp.task(loggedIOJsPath, false, [], (done) => {
887
915
const temp = path . join ( builtLocalDirectory , "temp" ) ;
888
916
mkdirP ( temp , ( err ) => {
889
917
if ( err ) { console . error ( err ) ; done ( err ) ; process . exit ( 1 ) ; } ;
890
- exec ( host , [ LKGCompiler , "--outdir" , temp , loggedIOpath ] , ( ) => {
918
+ exec ( host , [ LKGCompiler , "--types -- outdir" , temp , loggedIOpath ] , ( ) => {
891
919
fs . renameSync ( path . join ( temp , "/harness/loggedIO.js" ) , loggedIOJsPath ) ;
892
920
del ( temp ) . then ( ( ) => done ( ) , done ) ;
893
921
} , done ) ;
@@ -908,8 +936,8 @@ gulp.task(instrumenterJsPath, false, [servicesFile], () => {
908
936
. pipe ( gulp . dest ( "." ) ) ;
909
937
} ) ;
910
938
911
- gulp . task ( "tsc-instrumented" , "Builds an instrumented tsc.js" , [ loggedIOJsPath , instrumenterJsPath , servicesFile ] , ( done ) => {
912
- exec ( host , [ instrumenterJsPath , "record" , "iocapture" , builtLocalDirectory , compilerFilename ] , done , done ) ;
939
+ gulp . task ( "tsc-instrumented" , "Builds an instrumented tsc.js" , [ "local" , loggedIOJsPath , instrumenterJsPath , servicesFile ] , ( done ) => {
940
+ exec ( host , [ instrumenterJsPath , "record" , "iocapture" , builtLocalCompiler ] , done , done ) ;
913
941
} ) ;
914
942
915
943
gulp . task ( "update-sublime" , "Updates the sublime plugin's tsserver" , [ "local" , serverFile ] , ( ) => {
0 commit comments