Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

fix(@angular-devkit/build-angular): build with empty assets array #819

Merged
merged 1 commit into from
Apr 30, 2018
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 @@ -38,6 +38,13 @@ export function normalizeAssetPatterns(
const sourceRoot = maybeSourceRoot || join(projectRoot, 'src');
const resolvedSourceRoot = resolve(root, sourceRoot);

if (assetPatterns.length === 0) {
// If there are no asset patterns, return an empty array.
// It's important to do this because forkJoin with an empty array will immediately complete
// the observable.
return of([]);
}

const assetPatternObjectObservables: Observable<AssetPatternObject>[] = assetPatterns
.map(assetPattern => {
// Normalize string asset patterns to objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { normalize, virtualFs } from '@angular-devkit/core';
import { tap } from 'rxjs/operators';
import { tap, toArray } from 'rxjs/operators';
import { Timeout, browserTargetSpec, host, runTargetSpec } from '../utils';


Expand Down Expand Up @@ -91,4 +91,15 @@ describe('Browser Builder assets', () => {
// node_modules folder will hit this one and can fail.
host.scopedSync().delete(normalize('./node_modules'));
}, Timeout.Basic);

it('still builds with empty asset array', (done) => {
const overrides = {
assets: [],
};

runTargetSpec(host, browserTargetSpec, overrides).pipe(
toArray(),
tap((buildEvents) => expect(buildEvents.length).toBe(1)),
).subscribe(undefined, done.fail, done);
}, Timeout.Basic);
});