Skip to content

Commit dc03945

Browse files
author
Fatme
authored
Merge pull request #55 from NativeScript/fatme/fix-many-file-change-detected
Fix many 'file change detected' messages
2 parents 386df5c + 660295b commit dc03945

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/compiler.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,27 @@ function runTypeScriptCompiler(logger, projectDir, options) {
6464
var stringData = data.toString();
6565
// 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.
6666
// https://github.com/Microsoft/TypeScript/blob/master/src/compiler/sys.ts#L623
67-
if (stringData !== "\x1Bc") {
68-
logger.info(stringData);
67+
let filteredData = stringData
68+
.split("\n")
69+
.map(row => row.replace("\x1Bc", ""))
70+
.filter(r => !!r)
71+
.join("\n");
72+
73+
if (filteredData) {
74+
const logLevel = logger.getLevel();
75+
const isTraceLogLevel = logLevel && /trace/i.test(logLevel);
76+
77+
if (isTraceLogLevel) {
78+
nodeArgs.push("--listEmittedFiles");
79+
logger.trace(filteredData);
80+
}
81+
82+
// https://github.com/Microsoft/TypeScript/blob/e53e56cf8212e45d0ebdd6affe462d161c7e0dc5/src/compiler/watch.ts#L160
83+
if (!isTraceLogLevel && filteredData.indexOf("error") !== -1) {
84+
logger.info(filteredData);
85+
}
6986
}
87+
7088
if (options.watch && stringData.toLowerCase().indexOf("watching for file changes.") !== -1 && !isResolved) {
7189
isResolved = true;
7290
resolve();

0 commit comments

Comments
 (0)