Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 6c68c46

Browse files
committed
fix(@angular-devkit/schematics): add backward-compatibility to transformOptions
Before it was supposed to return the options directly, now allows for returning observable.
1 parent 6ac841a commit 6c68c46

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/angular_devkit/schematics/tools/file-system-engine-host-base.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ import { FileSystemHost } from './file-system-host';
2929
import { readJsonFile } from './file-system-utility';
3030

3131

32+
declare const Symbol: Symbol & {
33+
readonly observable: symbol;
34+
};
35+
36+
3237
export declare type OptionTransform<T extends object, R extends object>
3338
= (schematic: FileSystemSchematicDescription, options: T) => Observable<R>;
3439

@@ -89,7 +94,7 @@ export abstract class FileSystemEngineHostBase implements
8994
collection: FileSystemCollectionDesc,
9095
desc: Partial<FileSystemSchematicDesc>): FileSystemSchematicDesc;
9196

92-
private _transforms: OptionTransform<object, object>[] = [];
97+
private _transforms: OptionTransform<{}, {}>[] = [];
9398

9499
/**
95100
* @deprecated Use `listSchematicNames`.
@@ -244,7 +249,14 @@ export abstract class FileSystemEngineHostBase implements
244249
): Observable<ResultT> {
245250
return (Observable.of(options)
246251
.pipe(
247-
...this._transforms.map(tFn => mergeMap(opt => tFn(schematic, opt))),
252+
...this._transforms.map(tFn => mergeMap(opt => {
253+
const newOptions = tFn(schematic, opt);
254+
if (Symbol.observable in newOptions) {
255+
return newOptions;
256+
} else {
257+
return Observable.of(newOptions);
258+
}
259+
})),
248260
)) as {} as Observable<ResultT>;
249261
}
250262

0 commit comments

Comments
 (0)