all-of.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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.dev/license
  8. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. const rxjs_1 = require("rxjs");
  11. const src_1 = require("../src");
  12. exports.default = (0, src_1.createBuilder)((options, context) => {
  13. const allRuns = [];
  14. context.reportProgress(0, (options.targets ? options.targets.length : 0) +
  15. (options.builders ? options.builders.length : 0));
  16. if (options.targets) {
  17. allRuns.push(...options.targets.map(({ target: targetStr, overrides }, i) => {
  18. const [project, target, configuration] = targetStr.split(/:/g, 3);
  19. return context
  20. .scheduleTarget({ project, target, configuration }, overrides || {})
  21. .then((run) => [i, run]);
  22. }));
  23. }
  24. if (options.builders) {
  25. allRuns.push(...options.builders.map(({ builder, options }, i) => {
  26. return context
  27. .scheduleBuilder(builder, options || {})
  28. .then((run) => [i, run]);
  29. }));
  30. }
  31. const allResults = allRuns.map(() => null);
  32. let n = 0;
  33. context.reportProgress(n++, allRuns.length);
  34. return (0, rxjs_1.from)(allRuns).pipe((0, rxjs_1.mergeMap)((runPromise) => (0, rxjs_1.from)(runPromise)), (0, rxjs_1.mergeMap)(([i, run]) => run.output.pipe((0, rxjs_1.map)((output) => [i, output]))), (0, rxjs_1.mergeMap)(([i, output]) => {
  35. allResults[i] = output;
  36. context.reportProgress(n++, allRuns.length);
  37. if (allResults.some((x) => x === null)) {
  38. // Some builders aren't done running yet.
  39. return rxjs_1.EMPTY;
  40. }
  41. else {
  42. return (0, rxjs_1.of)({
  43. success: allResults.every((x) => (x ? x.success : false)),
  44. });
  45. }
  46. }));
  47. });