Skip to content

Commit

Permalink
Merge pull request #2070 from m4tt72/feat/allow-disable-manual-restar…
Browse files Browse the repository at this point in the history
…t-watchmode

feat: allow disabling manual restart for ts watchmode
  • Loading branch information
kamilmysliwiec committed May 17, 2023
2 parents a707098 + 6e3e397 commit 1bedd79
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
32 changes: 21 additions & 11 deletions lib/compiler/watch-compiler.ts
Expand Up @@ -58,6 +58,12 @@ export class WatchCompiler {
this.createWatchStatusChanged(origWatchStatusReporter, onSuccess),
);

const manualRestart = getValueOrDefault(
configuration,
'compilerOptions.manualRestart',
appName,
);

const pluginsConfig = getValueOrDefault(
configuration,
'compilerOptions.plugins',
Expand All @@ -72,7 +78,9 @@ export class WatchCompiler {
host: ts.CompilerHost,
oldProgram: ts.EmitAndSemanticDiagnosticsBuilderProgram,
) => {
displayManualRestartTip();
if (manualRestart) {
displayManualRestartTip();
}

const tsconfigPathsPlugin = options
? tsconfigPathsBeforeHookFactory(options)
Expand Down Expand Up @@ -128,16 +136,18 @@ export class WatchCompiler {

const watchProgram = tsBin.createWatchProgram(host);

listenForManualRestart(() => {
watchProgram.close();
this.run(
configuration,
configFilename,
appName,
tsCompilerOptions,
onSuccess,
);
});
if (manualRestart) {
listenForManualRestart(() => {
watchProgram.close();
this.run(
configuration,
configFilename,
appName,
tsCompilerOptions,
onSuccess,
);
});
}
}

private createDiagnosticReporter(
Expand Down
1 change: 1 addition & 0 deletions lib/configuration/configuration.ts
Expand Up @@ -23,6 +23,7 @@ interface CompilerOptions {
plugins?: string[] | PluginOptions[];
assets?: string[];
deleteOutDir?: boolean;
manualRestart?: boolean;
}

interface PluginOptions {
Expand Down
1 change: 1 addition & 0 deletions lib/configuration/defaults.ts
Expand Up @@ -15,6 +15,7 @@ export const defaultConfiguration: Required<Configuration> = {
webpackConfigPath: 'webpack.config.js',
plugins: [],
assets: [],
manualRestart: false,
},
generateOptions: {},
};
Expand Down
2 changes: 2 additions & 0 deletions test/lib/configuration/nest-configuration.loader.spec.ts
Expand Up @@ -52,6 +52,7 @@ describe('Nest Configuration Loader', () => {
tsConfigPath: 'tsconfig.json',
webpack: false,
webpackConfigPath: 'webpack.config.js',
manualRestart: false,
},
generateOptions: {},
});
Expand All @@ -76,6 +77,7 @@ describe('Nest Configuration Loader', () => {
tsConfigPath: 'tsconfig.json',
webpack: false,
webpackConfigPath: 'webpack.config.js',
manualRestart: false,
},
generateOptions: {},
});
Expand Down

0 comments on commit 1bedd79

Please sign in to comment.