From 0d32570c026c1b8a47cd38ba5bf642c72ef39a50 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 26 Apr 2016 14:35:51 -0700 Subject: [PATCH] add dirWatcher for "watch" option in tsconfig.json --- src/compiler/tsc.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 2e40cfdc53c..d6dfc9eca8d 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -432,6 +432,16 @@ namespace ts { return sys.exit(compileResult.exitStatus); } + if (!directoryWatcher && sys.watchDirectory && configFileName) { + const directory = ts.getDirectoryPath(configFileName); + directoryWatcher = sys.watchDirectory( + // When the configFileName is just "tsconfig.json", the watched directory should be + // the current directory; if there is a given "project" parameter, then the configFileName + // is an absolute file name. + directory == "" ? "." : directory, + watchedDirectoryChanged, /*recursive*/ true); + } + setCachedProgram(compileResult.program); reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); }