diff --git a/packages/angular_devkit/build_angular/test/browser/output-path_spec_large.ts b/packages/angular_devkit/build_angular/test/browser/output-path_spec_large.ts index 53f819eae4b5..f661a9cecade 100644 --- a/packages/angular_devkit/build_angular/test/browser/output-path_spec_large.ts +++ b/packages/angular_devkit/build_angular/test/browser/output-path_spec_large.ts @@ -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'; @@ -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(); });