diff --git a/build/lib/reporter.js b/build/lib/reporter.js index 11f360b551a..795cc26d296 100644 --- a/build/lib/reporter.js +++ b/build/lib/reporter.js @@ -6,6 +6,8 @@ var es = require("event-stream"); var _ = require("underscore"); var util = require("gulp-util"); +var fs = require("fs"); +var path = require("path"); var allErrors = []; var startTime = null; var count = 0; @@ -22,9 +24,24 @@ function onEnd() { } log(); } +var buildLogPath = path.join(path.dirname(path.dirname(__dirname)), '.build', 'log'); +try { + fs.mkdirSync(path.dirname(buildLogPath)); +} +catch (err) { +} function log() { var errors = _.flatten(allErrors); errors.map(function (err) { return util.log(util.colors.red('Error') + ": " + err); }); + var regex = /^([^(]+)\((\d+),(\d+)\): (.*)$/; + var messages = errors + .map(function (err) { return regex.exec(err); }) + .filter(function (match) { return !!match; }) + .map(function (_a) { + var path = _a[1], line = _a[2], column = _a[3], message = _a[4]; + return ({ path: path, line: Number.parseInt(line), column: Number.parseInt(column), message: message }); + }); + fs.writeFileSync(buildLogPath, JSON.stringify(messages)); util.log("Finished " + util.colors.green('compilation') + " with " + errors.length + " errors after " + util.colors.magenta((new Date().getTime() - startTime) + ' ms')); } function createReporter() { diff --git a/build/lib/reporter.ts b/build/lib/reporter.ts index d25e08a8731..10f9018c40d 100644 --- a/build/lib/reporter.ts +++ b/build/lib/reporter.ts @@ -8,6 +8,8 @@ import * as es from 'event-stream'; import * as _ from 'underscore'; import * as util from 'gulp-util'; +import * as fs from 'fs'; +import * as path from 'path'; const allErrors: Error[][] = []; let startTime: number = null; @@ -30,10 +32,26 @@ function onEnd(): void { log(); } +const buildLogPath = path.join(path.dirname(path.dirname(__dirname)), '.build', 'log'); + +try { + fs.mkdirSync(path.dirname(buildLogPath)); +} catch (err) { + // ignore +} + function log(): void { const errors = _.flatten(allErrors); errors.map(err => util.log(`${util.colors.red('Error')}: ${err}`)); + const regex = /^([^(]+)\((\d+),(\d+)\): (.*)$/; + const messages = errors + .map(err => regex.exec(err)) + .filter(match => !!match) + .map(([, path, line, column, message]) => ({ path, line: Number.parseInt(line), column: Number.parseInt(column), message })); + + fs.writeFileSync(buildLogPath, JSON.stringify(messages)); + util.log(`Finished ${util.colors.green('compilation')} with ${errors.length} errors after ${util.colors.magenta((new Date().getTime() - startTime) + ' ms')}`); }