Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix style
  • Loading branch information
weswigham committed Aug 15, 2016
commit 67a36229df1ebd03829cc17cc103ee80497c268d
8 changes: 4 additions & 4 deletions Gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ const lintTargets = [
"tests/*.ts", "tests/webhost/*.ts" // Note: does *not* descend recursively
];

function sendNextFile(files, child, callback, failures) {
function sendNextFile(files: {path: string}[], child: cp.ChildProcess, callback: (failures: number) => void, failures: number) {
const file = files.pop();
if (file) {
console.log(`Linting '${file.path}'.`);
Expand All @@ -951,7 +951,7 @@ function sendNextFile(files, child, callback, failures) {
}
}

function spawnLintWorker(files, callback) {
function spawnLintWorker(files: {path: string}[], callback: (failures: number) => void) {
const child = cp.fork("./scripts/parallel-lint");
let failures = 0;
child.on("message", function(data) {
Expand All @@ -977,13 +977,13 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
const fileMatcher = RegExp(cmdLineOptions["files"]);
if (fold.isTravis()) console.log(fold.start("lint"));

const files = [];
const files: {stat: fs.Stats, path: string}[] = [];
return gulp.src(lintTargets, { read: false })
.pipe(through2.obj((chunk, enc, cb) => {
files.push(chunk);
cb();
}, (cb) => {
files.sort((filea, fileb) => filea.stat.size - fileb.stat.size).filter(file => fileMatcher.test(file.path));
files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size);
const workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length;
for (let i = 0; i < workerCount; i++) {
spawnLintWorker(files, finished);
Expand Down
28 changes: 14 additions & 14 deletions scripts/parallel-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function lintFileContents(options, path, contents) {
}

function lintFileAsync(options, path, cb) {
fs.readFile(path, "utf8", function(err, contents) {
fs.readFile(path, "utf8", function (err, contents) {
if (err) {
return cb(err);
}
Expand All @@ -25,21 +25,21 @@ function lintFileAsync(options, path, cb) {
});
}

process.on("message", function(data) {
process.on("message", function (data) {
switch (data.kind) {
case "file":
var target = data.name;
var lintOptions = getLinterOptions();
lintFileAsync(lintOptions, target, function(err, result) {
if (err) {
process.send({kind: "error", error: err.toString()});
return;
}
process.send({kind: "result", failures: result.failureCount, output: result.output});
});
break;
var target = data.name;
var lintOptions = getLinterOptions();
lintFileAsync(lintOptions, target, function (err, result) {
if (err) {
process.send({ kind: "error", error: err.toString() });
return;
}
process.send({ kind: "result", failures: result.failureCount, output: result.output });
});
break;
case "close":
process.exit(0);
break;
process.exit(0);
break;
}
});