Skip to content

Commit c3caf7f

Browse files
committed
Merge branch 'mihailik-patch-1'
2 parents e2c9555 + 54ae270 commit c3caf7f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/compiler/tsc.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ namespace ts {
239239
function isJSONSupported() {
240240
return typeof JSON === "object" && typeof JSON.parse === "function";
241241
}
242+
243+
function isWatchSet(options: CompilerOptions) {
244+
// Firefox has Object.prototype.watch
245+
return options.watch && options.hasOwnProperty("watch");
246+
}
242247

243248
export function executeCommandLine(args: string[]): void {
244249
const commandLine = parseCommandLine(args);
@@ -327,8 +332,7 @@ namespace ts {
327332
return sys.exit(ExitStatus.Success);
328333
}
329334

330-
// Firefox has Object.prototype.watch
331-
if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) {
335+
if (isWatchSet(commandLine.options)) {
332336
if (!sys.watchFile) {
333337
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined);
334338
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
@@ -415,7 +419,7 @@ namespace ts {
415419

416420
const compileResult = compile(rootFileNames, compilerOptions, compilerHost);
417421

418-
if (!compilerOptions.watch) {
422+
if (!isWatchSet(compilerOptions)) {
419423
return sys.exit(compileResult.exitStatus);
420424
}
421425

@@ -441,7 +445,7 @@ namespace ts {
441445
}
442446
// Use default host function
443447
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
444-
if (sourceFile && compilerOptions.watch) {
448+
if (sourceFile && isWatchSet(compilerOptions)) {
445449
// Attach a file watcher
446450
const filePath = toPath(sourceFile.fileName, sys.getCurrentDirectory(), createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
447451
sourceFile.fileWatcher = sys.watchFile(filePath, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));

0 commit comments

Comments
 (0)