Skip to content

Commit 9fca29a

Browse files
clydinvikerman
authored andcommitted
refactor(@angular-devkit/build-angular): use copy file utility in action cache
1 parent 2b41cd1 commit 9fca29a

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

packages/angular_devkit/build_angular/src/browser/action-cache.ts

+2-20
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,14 @@
88
import { createHash } from 'crypto';
99
import * as findCacheDirectory from 'find-cache-dir';
1010
import * as fs from 'fs';
11+
import { copyFile } from '../utils/copy-file';
1112
import { manglingDisabled } from '../utils/mangle-options';
1213
import { CacheKey, ProcessBundleOptions, ProcessBundleResult } from '../utils/process-bundle';
1314

1415
const cacache = require('cacache');
1516
const cacheDownlevelPath = findCacheDirectory({ name: 'angular-build-dl' });
1617
const 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-
2819
export 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

Comments
 (0)