8
8
import { createHash } from 'crypto' ;
9
9
import * as findCacheDirectory from 'find-cache-dir' ;
10
10
import * as fs from 'fs' ;
11
+ import { copyFile } from '../utils/copy-file' ;
11
12
import { manglingDisabled } from '../utils/mangle-options' ;
12
13
import { CacheKey , ProcessBundleOptions , ProcessBundleResult } from '../utils/process-bundle' ;
13
14
14
15
const cacache = require ( 'cacache' ) ;
15
16
const cacheDownlevelPath = findCacheDirectory ( { name : 'angular-build-dl' } ) ;
16
17
const packageVersion = require ( '../../package.json' ) . version ;
17
18
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
-
28
19
export interface CacheEntry {
29
20
path : string ;
30
21
size : number ;
@@ -35,17 +26,8 @@ export class BundleActionCache {
35
26
constructor ( private readonly integrityAlgorithm ?: string ) { }
36
27
37
28
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 ) ;
43
30
44
- fs . copyFileSync (
45
- typeof entry === 'string' ? entry : entry . path ,
46
- dest ,
47
- fs . constants . COPYFILE_FICLONE ,
48
- ) ;
49
31
if ( process . platform !== 'win32' ) {
50
32
// The cache writes entries as readonly and when using copyFile the permissions will also be copied.
51
33
// See: https://github.com/npm/cacache/blob/073fbe1a9f789ba42d9a41de7b8429c93cf61579/lib/util/move-file.js#L36
0 commit comments