Skip to content

Commit 2fc4189

Browse files
committed
fix(@angular-devkit/build-angular): workaround Node.js copyFile defect on macOS
Fixes #15544
1 parent 4aaec9c commit 2fc4189

File tree

1 file changed

+16
-0
lines changed
  • packages/angular_devkit/build_angular/src/browser

1 file changed

+16
-0
lines changed

packages/angular_devkit/build_angular/src/browser/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,23 @@ export function buildWebpackBrowser(
471471
}
472472
}
473473

474+
// Workaround Node.js issue prior to 10.16 with copyFile on macOS
475+
// https://github.com/angular/angular-cli/issues/15544 & https://github.com/nodejs/node/pull/27241
476+
let copyFileWorkaround = false;
477+
if (process.platform === 'darwin') {
478+
const version = process.versions.node.split('.').map(part => Number(part));
479+
if (version[0] < 10 || version[0] === 11 || version[0] === 10 && version[1] < 16) {
480+
copyFileWorkaround = true;
481+
}
482+
}
483+
474484
for (const action of cacheActions) {
485+
if (copyFileWorkaround) {
486+
try {
487+
fs.unlinkSync(action.dest);
488+
} catch {}
489+
}
490+
475491
fs.copyFileSync(action.src, action.dest, fs.constants.COPYFILE_FICLONE);
476492
if (process.platform !== 'win32') {
477493
// The cache writes entries as readonly and when using copyFile the permissions will also be copied.

0 commit comments

Comments
 (0)