mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from master
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user