Skip to content

fix(@angular-devkit/build-angular): exit localized build when CTRL+C is pressed #23457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions packages/angular_devkit/build_angular/src/utils/i18n-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ export async function configureI18nBuild<T extends BrowserBuilderSchema | Server

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

process.on('exit', () => deleteTempDirectory(tempPath));
process.once('SIGINT', () => {
deleteTempDirectory(tempPath);

// Needed due to `ora` as otherwise process will not terminate.
process.kill(process.pid, 'SIGINT');
process.on('exit', () => {
try {
fs.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
} catch {}
});
}

Expand All @@ -273,13 +273,6 @@ function findLocaleDataPath(locale: string, resolver: (locale: string) => string
}
}

/** Remove temporary directory used for i18n processing. */
function deleteTempDirectory(tempPath: string): void {
try {
fs.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
} catch {}
}

export function loadTranslations(
locale: string,
desc: LocaleDescription,
Expand Down