Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import fs from 'node:fs/promises';
import { buildApplication } from '../../index';
import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setup';

Expand Down Expand Up @@ -408,6 +409,44 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {

harness.expectFile('dist/browser/test.svg').toNotExist();
});

it('does not follow symlink directories by default', async () => {
await harness.writeFile('target/test.txt', 'symlink-content');
await fs.symlink(
harness.resolvePath('target'),
harness.resolvePath('src/symlink-dir'),
'junction',
);

harness.useTarget('build', {
...BASE_OPTIONS,
assets: [{ glob: '**/*', input: 'src' }],
});

const { result } = await harness.executeOnce();

expect(result?.success).toBe(true);
harness.expectFile('dist/browser/symlink-dir/test.txt').toNotExist();
});

it('follows symlink directories when followSymlinks is true', async () => {
await harness.writeFile('target/test.txt', 'symlink-content');
await fs.symlink(
harness.resolvePath('target'),
harness.resolvePath('src/symlink-dir'),
'junction',
);

harness.useTarget('build', {
...BASE_OPTIONS,
assets: [{ glob: '**/*', input: 'src', followSymlinks: true }],
});

const { result } = await harness.executeOnce();

expect(result?.success).toBe(true);
harness.expectFile('dist/browser/symlink-dir/test.txt').content.toBe('symlink-content');
});
});
});
});
2 changes: 1 addition & 1 deletion packages/angular/build/src/utils/resolve-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function resolveAssets(
cwd,
dot: true,
ignore: entry.ignore ? [...DEFAULT_ASSET_IGNORE, ...entry.ignore] : DEFAULT_ASSET_IGNORE,
followSymbolicLinks: entry.followSymlinks,
followSymbolicLinks: entry.followSymlinks ?? false,
});

for (const file of files) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function copyAssets(
cwd,
dot: true,
ignore: entry.ignore ? defaultIgnore.concat(entry.ignore) : defaultIgnore,
followSymbolicLinks: entry.followSymlinks,
followSymbolicLinks: entry.followSymlinks ?? false,
});

const directoryExists = new Set<string>();
Expand Down
Loading