From cff98d529493b8775d8724c3c1fdfe7d2bffa876 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 27 Apr 2016 14:40:59 -0700 Subject: [PATCH] Move the dir watcher to parseConfigFile --- src/compiler/tsc.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index d6dfc9eca8d..e25ae37e21f 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -391,9 +391,21 @@ namespace ts { sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); return; } - if (isWatchSet(configParseResult.options) && !sys.watchFile) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined); - sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + if (isWatchSet(configParseResult.options)) { + if (!sys.watchFile) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined); + sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + + 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); + }; } return configParseResult; } @@ -432,16 +444,6 @@ 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)); }