executor.js 1.1 KB

1234567891011121314151617181920212223242526272829
  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. exports.default = default_1;
  11. function default_1() {
  12. return (options, context) => {
  13. if (!options?.name) {
  14. throw new Error('RunSchematicTask requires an options object with a non-empty name property.');
  15. }
  16. const maybeWorkflow = context.engine.workflow;
  17. const collection = options.collection || context.schematic.collection.description.name;
  18. if (!maybeWorkflow) {
  19. throw new Error('Need Workflow to support executing schematics as post tasks.');
  20. }
  21. return maybeWorkflow.execute({
  22. collection: collection,
  23. schematic: options.name,
  24. options: options.options,
  25. // Allow private when calling from the same collection.
  26. allowPrivate: collection == context.schematic.collection.description.name,
  27. });
  28. };
  29. }