Skip to content

Commit 96840c3

Browse files
committed
Merge branch 'master' into allow-js-multiple-declaration-of-constructor-properties
2 parents 2845d2f + 0006371 commit 96840c3

File tree

215 files changed

+6819
-1406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+6819
-1406
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ node_js:
77

88
sudo: false
99

10+
env:
11+
- workerCount=3
12+
1013
matrix:
1114
fast_finish: true
1215
include:
1316
- os: osx
1417
node_js: stable
1518
osx_image: xcode7.3
19+
env: workerCount=2
20+
allow_failures:
21+
- os: osx
1622

1723
branches:
1824
only:
@@ -28,3 +34,6 @@ install:
2834
cache:
2935
directories:
3036
- node_modules
37+
38+
git:
39+
depth: 1

Gulpfile.ts

Lines changed: 64 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import through2 = require("through2");
3434
import merge2 = require("merge2");
3535
import intoStream = require("into-stream");
3636
import * as os from "os";
37-
import Linter = require("tslint");
37+
import fold = require("travis-fold");
3838
const gulp = helpMaker(originalGulp);
3939
const mochaParallel = require("./scripts/mocha-parallel.js");
4040
const {runTestsInParallel} = mochaParallel;
@@ -449,7 +449,7 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
449449
});
450450

451451
gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]);
452-
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON]);
452+
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]);
453453
gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]);
454454

455455

@@ -503,7 +503,7 @@ gulp.task("VerifyLKG", false, [], () => {
503503
return gulp.src(expectedFiles).pipe(gulp.dest(LKGDirectory));
504504
});
505505

506-
gulp.task("LKGInternal", false, ["lib", "local", "lssl"]);
506+
gulp.task("LKGInternal", false, ["lib", "local"]);
507507

508508
gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUseDebugMode"], () => {
509509
return runSequence("LKGInternal", "VerifyLKG");
@@ -928,26 +928,6 @@ gulp.task("build-rules", "Compiles tslint rules to js", () => {
928928
.pipe(gulp.dest(dest));
929929
});
930930

931-
function getLinterOptions() {
932-
return {
933-
configuration: require("./tslint.json"),
934-
formatter: "prose",
935-
formattersDirectory: undefined,
936-
rulesDirectory: "built/local/tslint"
937-
};
938-
}
939-
940-
function lintFileContents(options, path, contents) {
941-
const ll = new Linter(path, contents, options);
942-
console.log("Linting '" + path + "'.");
943-
return ll.lint();
944-
}
945-
946-
function lintFile(options, path) {
947-
const contents = fs.readFileSync(path, "utf8");
948-
return lintFileContents(options, path, contents);
949-
}
950-
951931
const lintTargets = [
952932
"Gulpfile.ts",
953933
"src/compiler/**/*.ts",
@@ -959,27 +939,72 @@ const lintTargets = [
959939
"tests/*.ts", "tests/webhost/*.ts" // Note: does *not* descend recursively
960940
];
961941

942+
function sendNextFile(files: {path: string}[], child: cp.ChildProcess, callback: (failures: number) => void, failures: number) {
943+
const file = files.pop();
944+
if (file) {
945+
console.log(`Linting '${file.path}'.`);
946+
child.send({ kind: "file", name: file.path });
947+
}
948+
else {
949+
child.send({ kind: "close" });
950+
callback(failures);
951+
}
952+
}
953+
954+
function spawnLintWorker(files: {path: string}[], callback: (failures: number) => void) {
955+
const child = cp.fork("./scripts/parallel-lint");
956+
let failures = 0;
957+
child.on("message", function(data) {
958+
switch (data.kind) {
959+
case "result":
960+
if (data.failures > 0) {
961+
failures += data.failures;
962+
console.log(data.output);
963+
}
964+
sendNextFile(files, child, callback, failures);
965+
break;
966+
case "error":
967+
console.error(data.error);
968+
failures++;
969+
sendNextFile(files, child, callback, failures);
970+
break;
971+
}
972+
});
973+
sendNextFile(files, child, callback, failures);
974+
}
962975

963976
gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => {
964977
const fileMatcher = RegExp(cmdLineOptions["files"]);
965-
const lintOptions = getLinterOptions();
966-
let failed = 0;
967-
return gulp.src(lintTargets)
968-
.pipe(insert.transform((contents, file) => {
969-
if (!fileMatcher.test(file.path)) return contents;
970-
const result = lintFile(lintOptions, file.path);
971-
if (result.failureCount > 0) {
972-
console.log(result.output);
973-
failed += result.failureCount;
978+
if (fold.isTravis()) console.log(fold.start("lint"));
979+
980+
let files: {stat: fs.Stats, path: string}[] = [];
981+
return gulp.src(lintTargets, { read: false })
982+
.pipe(through2.obj((chunk, enc, cb) => {
983+
files.push(chunk);
984+
cb();
985+
}, (cb) => {
986+
files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size);
987+
const workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length;
988+
for (let i = 0; i < workerCount; i++) {
989+
spawnLintWorker(files, finished);
974990
}
975-
return contents; // TODO (weswig): Automatically apply fixes? :3
976-
}))
977-
.on("end", () => {
978-
if (failed > 0) {
979-
console.error("Linter errors.");
980-
process.exit(1);
991+
992+
let completed = 0;
993+
let failures = 0;
994+
function finished(fails) {
995+
completed++;
996+
failures += fails;
997+
if (completed === workerCount) {
998+
if (fold.isTravis()) console.log(fold.end("lint"));
999+
if (failures > 0) {
1000+
throw new Error(`Linter errors: ${failures}`);
1001+
}
1002+
else {
1003+
cb();
1004+
}
1005+
}
9811006
}
982-
});
1007+
}));
9831008
});
9841009

9851010

0 commit comments

Comments
 (0)