[6a3a178] | 1 | "use strict";
|
---|
| 2 | /**
|
---|
| 3 | * @license
|
---|
| 4 | * Copyright Google LLC All Rights Reserved.
|
---|
| 5 | *
|
---|
| 6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 7 | * found in the LICENSE file at https://angular.io/license
|
---|
| 8 | */
|
---|
| 9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 10 | const rxjs_1 = require("rxjs");
|
---|
| 11 | const operators_1 = require("rxjs/operators");
|
---|
| 12 | const src_1 = require("../src");
|
---|
| 13 | exports.default = src_1.createBuilder((options, context) => {
|
---|
| 14 | const allRuns = [];
|
---|
| 15 | context.reportProgress(0, (options.targets ? options.targets.length : 0) +
|
---|
| 16 | (options.builders ? options.builders.length : 0));
|
---|
| 17 | if (options.targets) {
|
---|
| 18 | allRuns.push(...options.targets.map(({ target: targetStr, overrides }, i) => {
|
---|
| 19 | const [project, target, configuration] = targetStr.split(/:/g, 3);
|
---|
| 20 | return context
|
---|
| 21 | .scheduleTarget({ project, target, configuration }, overrides || {})
|
---|
| 22 | .then((run) => [i, run]);
|
---|
| 23 | }));
|
---|
| 24 | }
|
---|
| 25 | if (options.builders) {
|
---|
| 26 | allRuns.push(...options.builders.map(({ builder, options }, i) => {
|
---|
| 27 | return context
|
---|
| 28 | .scheduleBuilder(builder, options || {})
|
---|
| 29 | .then((run) => [i, run]);
|
---|
| 30 | }));
|
---|
| 31 | }
|
---|
| 32 | const allResults = allRuns.map(() => null);
|
---|
| 33 | let n = 0;
|
---|
| 34 | context.reportProgress(n++, allRuns.length);
|
---|
| 35 | return rxjs_1.from(allRuns).pipe(operators_1.mergeMap((runPromise) => rxjs_1.from(runPromise)), operators_1.mergeMap(([i, run]) => run.output.pipe(operators_1.map((output) => [i, output]))), operators_1.mergeMap(([i, output]) => {
|
---|
| 36 | allResults[i] = output;
|
---|
| 37 | context.reportProgress(n++, allRuns.length);
|
---|
| 38 | if (allResults.some((x) => x === null)) {
|
---|
| 39 | // Some builders aren't done running yet.
|
---|
| 40 | return rxjs_1.EMPTY;
|
---|
| 41 | }
|
---|
| 42 | else {
|
---|
| 43 | return rxjs_1.of({
|
---|
| 44 | success: allResults.every((x) => (x ? x.success : false)),
|
---|
| 45 | });
|
---|
| 46 | }
|
---|
| 47 | }));
|
---|
| 48 | });
|
---|