88import { createHash } from 'crypto' ;
99import * as findCacheDirectory from 'find-cache-dir' ;
1010import * as fs from 'fs' ;
11+ import { copyFile } from '../utils/copy-file' ;
1112import { manglingDisabled } from '../utils/mangle-options' ;
1213import { CacheKey , ProcessBundleOptions , ProcessBundleResult } from '../utils/process-bundle' ;
1314
1415const cacache = require ( 'cacache' ) ;
1516const cacheDownlevelPath = findCacheDirectory ( { name : 'angular-build-dl' } ) ;
1617const packageVersion = require ( '../../package.json' ) . version ;
1718
18- // Workaround Node.js issue prior to 10.16 with copyFile on macOS
19- // https://github.com/angular/angular-cli/issues/15544 & https://github.com/nodejs/node/pull/27241
20- let copyFileWorkaround = false ;
21- if ( process . platform === 'darwin' ) {
22- const version = process . versions . node . split ( '.' ) . map ( part => Number ( part ) ) ;
23- if ( version [ 0 ] < 10 || version [ 0 ] === 11 || ( version [ 0 ] === 10 && version [ 1 ] < 16 ) ) {
24- copyFileWorkaround = true ;
25- }
26- }
27-
2819export interface CacheEntry {
2920 path : string ;
3021 size : number ;
@@ -35,17 +26,8 @@ export class BundleActionCache {
3526 constructor ( private readonly integrityAlgorithm ?: string ) { }
3627
3728 static copyEntryContent ( entry : CacheEntry | string , dest : fs . PathLike ) : void {
38- if ( copyFileWorkaround ) {
39- try {
40- fs . unlinkSync ( dest ) ;
41- } catch { }
42- }
29+ copyFile ( typeof entry === 'string' ? entry : entry . path , dest ) ;
4330
44- fs . copyFileSync (
45- typeof entry === 'string' ? entry : entry . path ,
46- dest ,
47- fs . constants . COPYFILE_FICLONE ,
48- ) ;
4931 if ( process . platform !== 'win32' ) {
5032 // The cache writes entries as readonly and when using copyFile the permissions will also be copied.
5133 // See: https://github.com/npm/cacache/blob/073fbe1a9f789ba42d9a41de7b8429c93cf61579/lib/util/move-file.js#L36
0 commit comments