Skip to content

Commit 660295b

Browse files
committed
Fix many 'file change detected' messages
Fixes NativeScript/nativescript-cli#3687 When `tns run android` command is executed, a typescript watcher is started. When project is prepared {N} CLI moves all files in platforms directory. This triggers a typescript watcher to print `File change detected. Starting incremental compilation...` message many times. This PR hides all messages from typescript compiler except errors. So the user will see only typescript errors. Actually when the command is executed with --log trace option, all messages from typescript compiler will be printed.
1 parent a9604b8 commit 660295b

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)