|
8 | 8 |
|
9 | 9 | import { Architect } from '@angular-devkit/architect';
|
10 | 10 | import { getSystemPath, join, virtualFs } from '@angular-devkit/core';
|
| 11 | +import * as fs from 'fs'; |
11 | 12 | import { browserBuild, createArchitect, host } from '../utils';
|
12 | 13 |
|
13 | 14 |
|
@@ -39,13 +40,42 @@ describe('Browser Builder output path', () => {
|
39 | 40 | await run.stop();
|
40 | 41 | });
|
41 | 42 |
|
| 43 | + it('deletes output path and unlink symbolic link', async () => { |
| 44 | + // Write a file to the output path to later verify it was deleted. |
| 45 | + host.writeMultipleFiles({ |
| 46 | + 'src-link/dummy.txt': '', |
| 47 | + 'dist/file.txt': virtualFs.stringToFileBuffer('file'), |
| 48 | + }); |
| 49 | + |
| 50 | + const distLinked = join(host.root(), 'dist', 'linked'); |
| 51 | + |
| 52 | + // create symbolic link |
| 53 | + fs.symlinkSync( |
| 54 | + getSystemPath(join(host.root(), 'src-link')), |
| 55 | + getSystemPath(distLinked), |
| 56 | + 'junction', |
| 57 | + ); |
| 58 | + |
| 59 | + expect(await host.exists(distLinked).toPromise()).toBe(true); |
| 60 | + |
| 61 | + // Delete an app file to force a failed compilation. |
| 62 | + // Failed compilations still delete files, but don't output any. |
| 63 | + await host.delete(join(host.root(), 'src', 'app', 'app.component.ts')).toPromise(); |
| 64 | + const run = await architect.scheduleTarget(target); |
| 65 | + const output = await run.result; |
| 66 | + expect(output.success).toBe(false); |
| 67 | + |
| 68 | + expect(await host.exists(join(host.root(), 'dist')).toPromise()).toBe(false); |
| 69 | + expect(await host.exists(join(host.root(), 'src-link')).toPromise()).toBe(true); |
| 70 | + }); |
| 71 | + |
42 | 72 | it('does not allow output path to be project root', async () => {
|
43 | 73 | const overrides = { outputPath: './' };
|
44 | 74 | const run = await architect.scheduleTarget(target, overrides);
|
45 | 75 | try {
|
46 | 76 | await run.result;
|
47 | 77 | expect('THE ABOVE LINE SHOULD THROW').toBe('');
|
48 |
| - } catch {} |
| 78 | + } catch { } |
49 | 79 | await run.stop();
|
50 | 80 | });
|
51 | 81 |
|
|
0 commit comments