Skip to content

Commit 73fb927

Browse files
committed
fix: fix error messages filtering for typescript 3.1 as the new "Found 0 errors. Watching for file changes." info message was matching the errors filter.
1 parent fdade87 commit 73fb927

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

lib/compiler.js

+25-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ var fs = require('fs');
66
var path = require('path');
77
var semver = require('semver');
88
var tsc = null;
9+
var TscCompilationCompleteMessage = "watching for file changes";
10+
var TscWatcherInfoMessages = [
11+
"file change detected",
12+
"starting incremental compilation",
13+
TscCompilationCompleteMessage
14+
];
915

1016
function getTypeScriptVersion(typeScriptPath) {
1117
try {
@@ -30,7 +36,7 @@ function runTypeScriptCompiler(logger, projectDir, options) {
3036
var peerTypescriptPath = path.join(__dirname, '../../typescript');
3137
var tscPath = path.join(peerTypescriptPath, 'lib/tsc.js');
3238
var typeScriptVersion = getTypeScriptVersion(peerTypescriptPath);
33-
39+
3440
if (fs.existsSync(tscPath)) {
3541
logger.info(`Found peer TypeScript ${typeScriptVersion}`);
3642
} else {
@@ -56,6 +62,12 @@ function runTypeScriptCompiler(logger, projectDir, options) {
5662
nodeArgs.push('--preserveWatchOutput');
5763
}
5864

65+
const logLevel = logger.getLevel();
66+
const isTraceLogLevel = logLevel && /trace/i.test(logLevel);
67+
if (isTraceLogLevel) {
68+
nodeArgs.push("--listEmittedFiles");
69+
}
70+
5971
logger.trace(process.execPath, nodeArgs.join(' '));
6072
tsc = spawn(process.execPath, nodeArgs);
6173

@@ -71,24 +83,28 @@ function runTypeScriptCompiler(logger, projectDir, options) {
7183
.join("\n");
7284

7385
if (filteredData) {
74-
const logLevel = logger.getLevel();
75-
const isTraceLogLevel = logLevel && /trace/i.test(logLevel);
86+
var infoMessage = TscWatcherInfoMessages.find((info) => filteredData.toLowerCase().indexOf(info) !== -1);
87+
if (infoMessage) {
88+
if (options.watch && !isResolved && infoMessage === TscCompilationCompleteMessage) {
89+
isResolved = true;
90+
resolve();
91+
}
92+
93+
// ignore these info messages as they are spamming the CLI output
94+
// on each file generated in the platforms folder during prepare
95+
return;
96+
}
7697

7798
if (isTraceLogLevel) {
78-
nodeArgs.push("--listEmittedFiles");
7999
logger.trace(filteredData);
80100
}
81-
101+
82102
// https://github.com/Microsoft/TypeScript/blob/e53e56cf8212e45d0ebdd6affe462d161c7e0dc5/src/compiler/watch.ts#L160
83103
if (!isTraceLogLevel && filteredData.indexOf("error") !== -1) {
84104
logger.info(filteredData);
85105
}
86106
}
87107

88-
if (options.watch && stringData.toLowerCase().indexOf("watching for file changes.") !== -1 && !isResolved) {
89-
isResolved = true;
90-
resolve();
91-
}
92108
});
93109

94110
tsc.stderr.on('data', function (data) {

0 commit comments

Comments
 (0)