Skip to content

Commit 598a138

Browse files
clydinvikerman
authored andcommitted
fix(@angular-devkit/build-angular): workaround Node.js copyFile defect on macOS
Fixes #15544
1 parent 8595ec8 commit 598a138

File tree

1 file changed

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

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,27 @@ 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 (
480+
version[0] < 10 ||
481+
version[0] === 11 ||
482+
(version[0] === 10 && version[1] < 16)
483+
) {
484+
copyFileWorkaround = true;
485+
}
486+
}
487+
474488
for (const action of cacheActions) {
489+
if (copyFileWorkaround) {
490+
try {
491+
fs.unlinkSync(action.dest);
492+
} catch {}
493+
}
494+
475495
fs.copyFileSync(action.src, action.dest, fs.constants.COPYFILE_FICLONE);
476496
if (process.platform !== 'win32') {
477497
// The cache writes entries as readonly and when using copyFile the permissions will also be copied.

0 commit comments

Comments
 (0)