Skip to content

fix(@angular-devkit/build-angular): fix node 16 breaking when deleting the output path #21215

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

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import { rmdirSync } from 'fs';
import { existsSync, rmdirSync } from 'fs';
import { resolve } from 'path';

/**
Expand All @@ -18,5 +18,11 @@ export function deleteOutputDir(root: string, outputPath: string): void {
throw new Error('Output path MUST not be project root directory!');
}

rmdirSync(resolvedOutputPath, { recursive: true, maxRetries: 3 });
// NOTE: `recursive: true` does not silence errors about existence on node
// v16. `rmdirSync` recursive is deprecated and when node v14.14.0 is
// the default `rmSync` should be used with `force: true` in addition
// to the existing options.
if (existsSync(resolvedOutputPath)) {
rmdirSync(resolvedOutputPath, { recursive: true, maxRetries: 3 });
}
}