Skip to content

Commit e6838b6

Browse files
committed
Working on gulpifying things
1 parent 52a1659 commit e6838b6

1 file changed

Lines changed: 40 additions & 39 deletions

File tree

Gulpfile.ts

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import transform = require("vinyl-transform");
3030
import * as os from "os";
3131
import Linter = require("tslint");
3232
const gulp = helpMaker(originalGulp);
33-
import {runTestsInParallel} from "./scripts/mocha-parallel.js";
33+
const mochaParallel = require("./scripts/mocha-parallel.js");
34+
const {runTestsInParallel} = mochaParallel;
3435

3536
const cmdLineOptions = minimist(process.argv.slice(2), {
3637
boolean: ["debug", "light", "colors", "lint", "soft"],
@@ -464,8 +465,8 @@ gulp.task(importDefinitelyTypedTestsJs, false, [], () => {
464465
return gulp.src(importDefinitelyTypedTestsTs)
465466
.pipe(sourcemaps.init())
466467
.pipe(tsc(settings))
467-
.pipe(sourcemaps.write(path.dirname(importDefinitelyTypedTestsTs)))
468-
.pipe(gulp.dest(path.dirname(importDefinitelyTypedTestsTs)))
468+
.pipe(sourcemaps.write("."))
469+
.pipe(gulp.dest("."))
469470
});
470471

471472
gulp.task("importDefinitelyTypedTests", "Runs scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts to copy DT's tests to the TS-internal RWC tests", [importDefinitelyTypedTestsJs], (done) => {
@@ -490,13 +491,13 @@ gulp.task(processDiagnosticMessagesJs, false, [], () => {
490491
removeComments: true,
491492
noResolve: false,
492493
stripInternal: false,
493-
outFile: importDefinitelyTypedTestsJs
494+
outFile: processDiagnosticMessagesJs
494495
}, /*useBuiltCompiler*/ false);
495-
return gulp.src(importDefinitelyTypedTestsTs)
496+
return gulp.src(processDiagnosticMessagesTs)
496497
.pipe(sourcemaps.init())
497498
.pipe(tsc(settings))
498-
.pipe(sourcemaps.write(path.dirname(importDefinitelyTypedTestsTs)))
499-
.pipe(gulp.dest(path.dirname(importDefinitelyTypedTestsTs)))
499+
.pipe(sourcemaps.write("."))
500+
.pipe(gulp.dest("."))
500501
});
501502

502503
// The generated diagnostics map; built for the compiler and for the "generate-diagnostics" task
@@ -529,8 +530,8 @@ gulp.task(builtLocalCompiler, false, ["lib", "generate-diagnostics"], () => {
529530
if (!useDebugMode) {
530531
result = result.pipe(insert.prepend(fs.readFileSync(copyright)));
531532
}
532-
return result.pipe(sourcemaps.write(path.dirname(builtLocalCompiler)))
533-
.pipe(gulp.dest(path.dirname(builtLocalCompiler)));
533+
return result.pipe(sourcemaps.write("."))
534+
.pipe(gulp.dest("."));
534535
});
535536

536537
const servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
@@ -539,7 +540,7 @@ const nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
539540
const nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
540541
const nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_standalone.d.ts");
541542

542-
gulp.task(servicesFile, false, [], (done) => {
543+
gulp.task(servicesFile, false, [builtLocalCompiler], (done) => {
543544
const settings: tsc.Settings = getCompilerSettings({
544545
declaration: true,
545546
preserveConstEnums: true,
@@ -554,8 +555,8 @@ gulp.task(servicesFile, false, [], (done) => {
554555
if (!useDebugMode) {
555556
result = result.pipe(insert.prepend(fs.readFileSync(copyright)));
556557
}
557-
result.pipe(sourcemaps.write(path.dirname(builtLocalCompiler)))
558-
.pipe(gulp.dest(path.dirname(builtLocalCompiler)))
558+
result.pipe(sourcemaps.write("."))
559+
.pipe(gulp.dest("."))
559560
.on("end", () => {
560561
gulp.src(servicesFile).pipe(gulp.dest(nodePackageFile)).on("end", () => {
561562
// Stanalone/web definition file using global 'ts' namespace
@@ -582,7 +583,7 @@ gulp.task(servicesFile, false, [], (done) => {
582583

583584
const serverFile = path.join(builtLocalDirectory, "tsserver.js");
584585

585-
gulp.task(serverFile, false, [], () => {
586+
gulp.task(serverFile, false, [builtLocalCompiler], () => {
586587
const settings: tsc.Settings = getCompilerSettings({
587588
outFile: serverFile
588589
}, /*useBuiltCompiler*/ true);
@@ -592,14 +593,14 @@ gulp.task(serverFile, false, [], () => {
592593
if (!useDebugMode) {
593594
result = result.pipe(insert.prepend(fs.readFileSync(copyright)));
594595
}
595-
return result.pipe(sourcemaps.write(path.dirname(serverFile)))
596-
.pipe(gulp.dest(path.dirname(serverFile)));
596+
return result.pipe(sourcemaps.write("."))
597+
.pipe(gulp.dest("."));
597598
});
598599

599600
const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
600601
const tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
601602

602-
gulp.task(tsserverLibraryFile, false, [], () => {
603+
gulp.task(tsserverLibraryFile, false, [builtLocalCompiler], () => {
603604
const settings: tsc.Settings = getCompilerSettings({
604605
declaration: true,
605606
outFile: tsserverLibraryFile
@@ -610,8 +611,8 @@ gulp.task(tsserverLibraryFile, false, [], () => {
610611
if (!useDebugMode) {
611612
result = result.pipe(insert.prepend(fs.readFileSync(copyright)));
612613
}
613-
return result.pipe(sourcemaps.write(path.dirname(tsserverLibraryFile)))
614-
.pipe(gulp.dest(path.dirname(tsserverLibraryFile)));
614+
return result.pipe(sourcemaps.write("."))
615+
.pipe(gulp.dest("."));
615616
});
616617

617618
gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]);
@@ -632,8 +633,8 @@ gulp.task(word2mdJs, false, [], () => {
632633
return gulp.src(word2mdTs)
633634
.pipe(sourcemaps.init())
634635
.pipe(tsc(settings))
635-
.pipe(sourcemaps.write(path.dirname(word2mdJs)))
636-
.pipe(gulp.dest(path.dirname(word2mdJs)));
636+
.pipe(sourcemaps.write("."))
637+
.pipe(gulp.dest("."));
637638
});
638639

639640
gulp.task(specMd, false, [word2mdJs], (done) => {
@@ -675,15 +676,15 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", [], () => {
675676

676677
// Task to build the tests infrastructure using the built compiler
677678
const run = path.join(builtLocalDirectory, "run.js");
678-
gulp.task(run, false, [], () => {
679+
gulp.task(run, false, [builtLocalCompiler], () => {
679680
const settings: tsc.Settings = getCompilerSettings({
680681
outFile: run
681682
}, /*useBuiltCompiler*/ true);
682683
return gulp.src(harnessSources)
683684
.pipe(sourcemaps.init())
684685
.pipe(tsc(settings))
685-
.pipe(sourcemaps.write(path.dirname(run)))
686-
.pipe(gulp.dest(path.dirname(run)));
686+
.pipe(sourcemaps.write("."))
687+
.pipe(gulp.dest("."));
687688
});
688689

689690
const internalTests = "internal/";
@@ -698,7 +699,7 @@ const localTest262Baseline = path.join(internalTests, "baselines/test262/local")
698699
const refTest262Baseline = path.join(internalTests, "baselines/test262/reference");
699700

700701

701-
gulp.task("tests", "Builds the test infrastructure using the built compiler", ["local", run]);
702+
gulp.task("tests", "Builds the test infrastructure using the built compiler", [run]);
702703
gulp.task("tests-debug", "Builds the test sources and automation in debug mode", () => {
703704
return runSequence("useDebugMode", "tests");
704705
});
@@ -848,16 +849,16 @@ gulp.task("runtests",
848849

849850
const nodeServerOutFile = "tests/webTestServer.js";
850851
const nodeServerInFile = "tests/webTestServer.ts";
851-
gulp.task(run, false, [], () => {
852+
gulp.task(nodeServerOutFile, false, [builtLocalCompiler], () => {
852853
const settings: tsc.Settings = getCompilerSettings({}, /*useBuiltCompiler*/ true);
853854
return gulp.src(nodeServerInFile)
854855
.pipe(sourcemaps.init())
855856
.pipe(tsc(settings))
856-
.pipe(sourcemaps.write(path.dirname(nodeServerOutFile)))
857+
.pipe(sourcemaps.write('.'))
857858
.pipe(gulp.dest(path.dirname(nodeServerOutFile)));
858859
});
859860

860-
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", ["tests", run, nodeServerOutFile], (done) => {
861+
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [builtLocalCompiler, nodeServerOutFile], (done) => {
861862
// TODO (weswig): Use browserify JS api with gulp streams and correctly manage sourcemaps
862863
//exec(browserify, [run, "-d", "-o", "built/local/bundle.js"], done, done);
863864
const settings: tsc.Settings = getCompilerSettings({
@@ -869,8 +870,8 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
869870
.pipe(transform((filename) => {
870871
return browserify(filename).bundle();
871872
}))
872-
.pipe(sourcemaps.write(path.dirname(run)))
873-
.pipe(gulp.dest(path.dirname(run)));
873+
.pipe(sourcemaps.write("."))
874+
.pipe(gulp.dest("."));
874875
});
875876

876877

@@ -979,14 +980,14 @@ gulp.task("baseline-accept-test262", "Makes the most recent test262 test results
979980
// Webhost
980981
const webhostPath = "tests/webhost/webtsc.ts";
981982
const webhostJsPath = "tests/webhost/webtsc.js";
982-
gulp.task(run, false, [], () => {
983+
gulp.task(webhostJsPath, false, [builtLocalCompiler], () => {
983984
const settings: tsc.Settings = getCompilerSettings({
984985
outFile: webhostJsPath
985986
}, /*useBuiltCompiler*/ true);
986987
return gulp.src(webhostPath)
987988
.pipe(sourcemaps.init())
988989
.pipe(tsc(settings))
989-
.pipe(sourcemaps.write(path.dirname(webhostJsPath)))
990+
.pipe(sourcemaps.write("."))
990991
.pipe(gulp.dest(path.dirname(webhostJsPath)));
991992
});
992993

@@ -998,15 +999,15 @@ gulp.task("webhost", "Builds the tsc web host", [webhostJsPath], () => {
998999
// Perf compiler
9991000
const perftscPath = "tests/perftsc.ts";
10001001
const perftscJsPath = "built/local/perftsc.js";
1001-
gulp.task(run, false, [], () => {
1002+
gulp.task(perftscJsPath, false, [builtLocalCompiler], () => {
10021003
const settings: tsc.Settings = getCompilerSettings({
10031004
outFile: perftscJsPath
10041005
}, /*useBuiltCompiler*/ true);
10051006
return gulp.src(perftscPath)
10061007
.pipe(sourcemaps.init())
10071008
.pipe(tsc(settings))
1008-
.pipe(sourcemaps.write(path.dirname(perftscJsPath)))
1009-
.pipe(gulp.dest(path.dirname(perftscJsPath)));
1009+
.pipe(sourcemaps.write("."))
1010+
.pipe(gulp.dest("."));
10101011
});
10111012

10121013
gulp.task("perftsc", "Builds augmented version of the compiler for perf tests", [perftscJsPath]);
@@ -1028,15 +1029,15 @@ gulp.task(loggedIOJsPath, false, [], (done) => {
10281029

10291030
const instrumenterPath = path.join(harnessDirectory, "instrumenter.ts");
10301031
const instrumenterJsPath = path.join(builtLocalDirectory, "instrumenter.js");
1031-
gulp.task(run, false, [], () => {
1032+
gulp.task(instrumenterJsPath, false, [builtLocalCompiler], () => {
10321033
const settings: tsc.Settings = getCompilerSettings({
10331034
outFile: instrumenterJsPath
10341035
}, /*useBuiltCompiler*/ true);
10351036
return gulp.src(instrumenterPath)
10361037
.pipe(sourcemaps.init())
10371038
.pipe(tsc(settings))
1038-
.pipe(sourcemaps.write(path.dirname(instrumenterJsPath)))
1039-
.pipe(gulp.dest(path.dirname(instrumenterJsPath)));
1039+
.pipe(sourcemaps.write("."))
1040+
.pipe(gulp.dest("."));
10401041
});
10411042

10421043
gulp.task("tsc-instrumented", "Builds an instrumented tsc.js", [loggedIOJsPath, instrumenterJsPath, builtLocalCompiler], (done) => {
@@ -1067,8 +1068,8 @@ const tslintRulesOutFiles = tslintRules.map(function(p, i) {
10671068
return gulp.src(tslintRulesFiles[i])
10681069
.pipe(sourcemaps.init())
10691070
.pipe(tsc(settings))
1070-
.pipe(sourcemaps.write('.'))
1071-
.pipe(gulp.dest('.'));
1071+
.pipe(sourcemaps.write("."))
1072+
.pipe(gulp.dest("."));
10721073
});
10731074
return pathname;
10741075
});

0 commit comments

Comments
 (0)