Skip to content

Commit 6584f5f

Browse files
committed
refactor(@angular/build): remove Node.js v20 conditional file copying logic
The Node.js v20 `fs.copyFile` fallback has been removed in favor of `fs.cp`. This simplifies the file copying logic within the application builder, as `fs.cp` is now the standard for all supported Node.js versions. The related e2e test has also been updated to run unconditionally.
1 parent dfbbe2d commit 6584f5f

File tree

2 files changed

+5
-16
lines changed
  • packages/angular/build/src/builders/application
  • tests/e2e/tests/build

2 files changed

+5
-16
lines changed

packages/angular/build/src/builders/application/index.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import {
2828
import { Result, ResultKind } from './results';
2929
import { Schema as ApplicationBuilderOptions } from './schema';
3030

31-
const isNodeV22orHigher = Number(process.versions.node.split('.', 1)[0]) >= 22;
32-
3331
export type { ApplicationBuilderOptions };
3432

3533
export async function* buildApplicationInternal(
@@ -222,17 +220,10 @@ export async function* buildApplication(
222220
await fs.writeFile(fullFilePath, file.contents);
223221
} else {
224222
// Copy file contents
225-
if (isNodeV22orHigher) {
226-
// Use newer `cp` API on Node.js 22+ (minimum v22 for CLI is 22.11)
227-
await fs.cp(file.inputPath, fullFilePath, {
228-
mode: fs.constants.COPYFILE_FICLONE,
229-
preserveTimestamps: true,
230-
});
231-
} else {
232-
// For Node.js 20 use `copyFile` (`cp` is not stable for v20)
233-
// TODO: Remove when Node.js 20 is no longer supported
234-
await fs.copyFile(file.inputPath, fullFilePath, fs.constants.COPYFILE_FICLONE);
235-
}
223+
await fs.cp(file.inputPath, fullFilePath, {
224+
mode: fs.constants.COPYFILE_FICLONE,
225+
preserveTimestamps: true,
226+
});
236227
}
237228
});
238229

tests/e2e/tests/build/assets.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { updateJsonFile } from '../../utils/project';
66
import { expectToFail } from '../../utils/utils';
77
import { getGlobalVariable } from '../../utils/env';
88

9-
const isNodeV22orHigher = Number(process.versions.node.split('.', 1)[0]) >= 22;
10-
119
export default async function () {
1210
// Update the atime and mtime of the original file.
1311
// Note: Node.js has different time precision, which may cause mtime-based tests to fail.
@@ -28,7 +26,7 @@ export default async function () {
2826
await expectToFail(() => expectFileToExist('dist/test-project/browser/.gitkeep'));
2927

3028
// Timestamp preservation only supported with application build system on Node.js v22+
31-
if (isNodeV22orHigher && getGlobalVariable('argv')['esbuild']) {
29+
if (getGlobalVariable('argv')['esbuild']) {
3230
const [originalStats, outputStats] = await Promise.all([
3331
stat('public/favicon.ico'),
3432
stat('dist/test-project/browser/favicon.ico'),

0 commit comments

Comments
 (0)