Skip to content
Merged
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 @@ -8,6 +8,7 @@

import { Architect } from '@angular-devkit/architect';
import { getSystemPath, join, virtualFs } from '@angular-devkit/core';
import * as fs from 'fs';
import { browserBuild, createArchitect, host } from '../utils';


Expand Down Expand Up @@ -39,13 +40,42 @@ describe('Browser Builder output path', () => {
await run.stop();
});

it('deletes output path and unlink symbolic link', async () => {
// Write a file to the output path to later verify it was deleted.
host.writeMultipleFiles({
'src-link/dummy.txt': '',
'dist/file.txt': virtualFs.stringToFileBuffer('file'),
});

const distLinked = join(host.root(), 'dist', 'linked');

// create symbolic link
fs.symlinkSync(
getSystemPath(join(host.root(), 'src-link')),
getSystemPath(distLinked),
'junction',
);

expect(await host.exists(distLinked).toPromise()).toBe(true);

// Delete an app file to force a failed compilation.
// Failed compilations still delete files, but don't output any.
await host.delete(join(host.root(), 'src', 'app', 'app.component.ts')).toPromise();
const run = await architect.scheduleTarget(target);
const output = await run.result;
expect(output.success).toBe(false);

expect(await host.exists(join(host.root(), 'dist')).toPromise()).toBe(false);
expect(await host.exists(join(host.root(), 'src-link')).toPromise()).toBe(true);
});

it('does not allow output path to be project root', async () => {
const overrides = { outputPath: './' };
const run = await architect.scheduleTarget(target, overrides);
try {
await run.result;
expect('THE ABOVE LINE SHOULD THROW').toBe('');
} catch {}
} catch { }
await run.stop();
});

Expand Down