|
5 | 5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 |
| -import { analytics, experimental, isPromise, json, logging } from '@angular-devkit/core'; |
9 |
| -import { Observable, Subscription, from, isObservable, of, throwError } from 'rxjs'; |
| 8 | +import { analytics, experimental, json, logging } from '@angular-devkit/core'; |
| 9 | +import { Observable, Subscription, from, of, throwError } from 'rxjs'; |
10 | 10 | import { tap } from 'rxjs/operators';
|
11 | 11 | import {
|
12 | 12 | BuilderContext,
|
13 | 13 | BuilderHandlerFn,
|
14 | 14 | BuilderInfo,
|
15 | 15 | BuilderInput,
|
16 | 16 | BuilderOutput,
|
17 |
| - BuilderOutputLike, |
18 | 17 | BuilderProgressState,
|
19 | 18 | ScheduleOptions,
|
20 | 19 | Target,
|
21 | 20 | TypedBuilderProgress,
|
| 21 | + isBuilderOutput, |
22 | 22 | targetStringFromTarget,
|
23 | 23 | } from './api';
|
24 | 24 | import { Builder, BuilderSymbol, BuilderVersionSymbol } from './internal';
|
@@ -189,19 +189,18 @@ export function createBuilder<
|
189 | 189 | };
|
190 | 190 |
|
191 | 191 | context.reportRunning();
|
192 |
| - let result: BuilderOutputLike; |
| 192 | + let result; |
193 | 193 | try {
|
194 | 194 | result = fn(i.options as OptT, context);
|
| 195 | + if (isBuilderOutput(result)) { |
| 196 | + result = of(result); |
| 197 | + } else { |
| 198 | + result = from(result); |
| 199 | + } |
195 | 200 | } catch (e) {
|
196 | 201 | result = throwError(e);
|
197 | 202 | }
|
198 | 203 |
|
199 |
| - if (isPromise(result)) { |
200 |
| - result = from(result); |
201 |
| - } else if (!isObservable(result)) { |
202 |
| - result = of(result); |
203 |
| - } |
204 |
| - |
205 | 204 | // Manage some state automatically.
|
206 | 205 | progress({ state: BuilderProgressState.Running, current: 0, total: 1 }, context);
|
207 | 206 | subscriptions.push(result.pipe(
|
|
0 commit comments