Skip to content

Commit 51622bd

Browse files
pbrezinavikerman
authored andcommitted
fix(@angular-devkit/architect): add target to ScheduleOptions to allow its use in context.scheduleBuilder
A custom builder can call `context.scheduleBuilder` to call another builder. However, the following call will fail with `Must either have a target from the context or a default project.` exception because `scheduleBuilder` does not pass `target` to the called builder. ```typescript import { JsonObject } from '@angular-devkit/core' import { BuilderContext, BuilderOutput, BuilderRun, createBuilder } from '@angular-devkit/architect'; import { Observable, from } from 'rxjs'; import { concatMap, map } from 'rxjs/operators'; export default createBuilder(_customBuilder); function _customBuilder(options: JsonObject, context: BuilderContext): Observable<BuilderOutput> { const builder = '@angular-devkit/build-angular:browser'; return from(context.scheduleBuilder(builder, options)).pipe( concatMap(run => run.result) ); } ``` Resolves: #15053
1 parent 5df50ba commit 51622bd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

packages/angular_devkit/architect/src/api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ export interface ScheduleOptions {
109109
* to log a builder scheduled from your builder you should forward log events yourself.
110110
*/
111111
logger?: logging.Logger;
112+
113+
/**
114+
* Target to pass to the builder.
115+
*/
116+
target?: Target;
112117
}
113118

114119
/**

packages/angular_devkit/architect/src/create-builder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export function createBuilder<
129129
) {
130130
const run = await scheduleByName(builderName, options, {
131131
scheduler,
132+
target: scheduleOptions.target,
132133
logger: scheduleOptions.logger || logger.createChild(''),
133134
workspaceRoot: i.workspaceRoot,
134135
currentDirectory: i.currentDirectory,

0 commit comments

Comments
 (0)