Skip to content

Commit 0ebb81f

Browse files
committed
fix(@angular-devkit/build-angular): exit localized build when CTRL+C is pressed
When using localization we setup `SIGINT` signal to delete the temporary directory. In some cases these resulted in delaying the process from exiting a couple of seconds. Closes angular#22216
1 parent 39cc99c commit 0ebb81f

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

packages/angular_devkit/build_angular/src/utils/i18n-options.ts

+6-13
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,15 @@ export async function configureI18nBuild<T extends BrowserBuilderSchema | Server
246246

247247
// If inlining store the output in a temporary location to facilitate post-processing
248248
if (i18n.shouldInline) {
249+
// TODO: we should likely save these in the .angular directory in the next major version.
250+
// We'd need to do a migration to add the temp directory to gitignore.
249251
const tempPath = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'angular-cli-i18n-'));
250252
buildOptions.outputPath = tempPath;
251253

252-
process.on('exit', () => deleteTempDirectory(tempPath));
253-
process.once('SIGINT', () => {
254-
deleteTempDirectory(tempPath);
255-
256-
// Needed due to `ora` as otherwise process will not terminate.
257-
process.kill(process.pid, 'SIGINT');
254+
process.on('exit', () => {
255+
try {
256+
fs.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
257+
} catch {}
258258
});
259259
}
260260

@@ -273,13 +273,6 @@ function findLocaleDataPath(locale: string, resolver: (locale: string) => string
273273
}
274274
}
275275

276-
/** Remove temporary directory used for i18n processing. */
277-
function deleteTempDirectory(tempPath: string): void {
278-
try {
279-
fs.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
280-
} catch {}
281-
}
282-
283276
export function loadTranslations(
284277
locale: string,
285278
desc: LocaleDescription,

0 commit comments

Comments
 (0)