Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

View File

@@ -12,7 +12,7 @@ import * as fs from 'fs';
import * as path from 'path';
const allErrors: string[][] = [];
let startTime: number = null;
let startTime: number | null = null;
let count = 0;
function onStart(): void {
@@ -55,6 +55,7 @@ function log(): void {
const messages = errors
.map(err => regex.exec(err))
.filter(match => !!match)
.map(x => x as string[])
.map(([, path, line, column, message]) => ({ path, line: parseInt(line), column: parseInt(column), message }));
try {
@@ -64,7 +65,7 @@ function log(): void {
//noop
}
util.log(`Finished ${util.colors.green('compilation')} with ${errors.length} errors after ${util.colors.magenta((new Date().getTime() - startTime) + ' ms')}`);
util.log(`Finished ${util.colors.green('compilation')} with ${errors.length} errors after ${util.colors.magenta((new Date().getTime() - startTime!) + ' ms')}`);
}
export interface IReporter {
@@ -77,38 +78,32 @@ export function createReporter(): IReporter {
const errors: string[] = [];
allErrors.push(errors);
class ReportFunc {
constructor(err: string) {
errors.push(err);
}
const result = (err: string) => errors.push(err);
static hasErrors(): boolean {
return errors.length > 0;
}
result.hasErrors = () => errors.length > 0;
static end(emitError: boolean): NodeJS.ReadWriteStream {
errors.length = 0;
onStart();
result.end = (emitError: boolean): NodeJS.ReadWriteStream => {
errors.length = 0;
onStart();
return es.through(null, function () {
onEnd();
return es.through(undefined, function () {
onEnd();
if (emitError && errors.length > 0) {
(errors as any).__logged__ = true;
if (!(errors as any).__logged__) {
log();
}
const err = new Error(`Found ${errors.length} errors`);
(err as any).__reporter__ = true;
this.emit('error', err);
} else {
this.emit('end');
if (emitError && errors.length > 0) {
if (!(errors as any).__logged__) {
log();
}
});
}
}
return <IReporter><any>ReportFunc;
(errors as any).__logged__ = true;
const err = new Error(`Found ${errors.length} errors`);
(err as any).__reporter__ = true;
this.emit('error', err);
} else {
this.emit('end');
}
});
};
return result;
}