diff --git a/lib/compiler.js b/lib/compiler.js index 6a1cb36..e3a484d 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -64,9 +64,27 @@ function runTypeScriptCompiler(logger, projectDir, options) { var stringData = data.toString(); // Prevent console clear. Fixed the behaviour for typescript 2.7.1 and 2.7.2. Should be deleted after dropping support for 2.7.x version. // https://github.com/Microsoft/TypeScript/blob/master/src/compiler/sys.ts#L623 - if (stringData !== "\x1Bc") { - logger.info(stringData); + let filteredData = stringData + .split("\n") + .map(row => row.replace("\x1Bc", "")) + .filter(r => !!r) + .join("\n"); + + if (filteredData) { + const logLevel = logger.getLevel(); + const isTraceLogLevel = logLevel && /trace/i.test(logLevel); + + if (isTraceLogLevel) { + nodeArgs.push("--listEmittedFiles"); + logger.trace(filteredData); + } + + // https://github.com/Microsoft/TypeScript/blob/e53e56cf8212e45d0ebdd6affe462d161c7e0dc5/src/compiler/watch.ts#L160 + if (!isTraceLogLevel && filteredData.indexOf("error") !== -1) { + logger.info(filteredData); + } } + if (options.watch && stringData.toLowerCase().indexOf("watching for file changes.") !== -1 && !isResolved) { isResolved = true; resolve();