| 49 | * @param options The options to pass as input to the RuleFactory. |
| 50 | */ |
| 51 | export function schematic<OptionT extends object>( |
| 52 | schematicName: string, |
| 53 | options: OptionT, |
| 54 | executionOptions?: Partial<ExecutionOptions>, |
| 55 | ): Rule { |
| 56 | return (input: Tree, context: SchematicContext) => { |
| 57 | const collection = context.schematic.collection; |
| 58 | const schematic = collection.createSchematic(schematicName, true); |
| 59 | |
| 60 | return schematic.call(options, observableOf(branch(input)), context, executionOptions).pipe( |
| 61 | last(), |
| 62 | map((x) => { |
| 63 | // We allow overwrite conflict here because they're the only merge conflict we particularly |
| 64 | // don't want to deal with; the input tree might have an OVERWRITE which the sub |
| 65 | input.merge(x, MergeStrategy.AllowOverwriteConflict); |
| 66 | |
| 67 | return input; |
| 68 | }), |
| 69 | ); |
| 70 | }; |
| 71 | } |