File tree Expand file tree Collapse file tree 3 files changed +29
-13
lines changed
packages/angular_devkit/schematics/tasks/run-schematic Expand file tree Collapse file tree 3 files changed +29
-13
lines changed Original file line number Diff line number Diff line change @@ -9,18 +9,21 @@ import { SchematicContext, TaskExecutor } from '../../src';
99import { RunSchematicTaskOptions } from './options' ;
1010
1111
12- export default function ( ) : TaskExecutor < RunSchematicTaskOptions > {
13- return ( options : RunSchematicTaskOptions , context : SchematicContext ) => {
12+ export default function ( ) : TaskExecutor < RunSchematicTaskOptions < { } > > {
13+ return ( options : RunSchematicTaskOptions < { } > , context : SchematicContext ) => {
1414 const maybeWorkflow = context . engine . workflow ;
15+ const collection = options . collection || context . schematic . collection . description . name ;
1516
1617 if ( ! maybeWorkflow ) {
1718 throw new Error ( 'Need Workflow to support executing schematics as post tasks.' ) ;
1819 }
1920
2021 return maybeWorkflow . execute ( {
21- collection : options . collection ,
22+ collection : collection ,
2223 schematic : options . name ,
2324 options : options . options ,
25+ // Allow private when calling from the same collection.
26+ allowPrivate : collection == context . schematic . collection . description . name ,
2427 } ) ;
2528 } ;
2629}
Original file line number Diff line number Diff line change 77 */
88export const RunSchematicName = 'run-schematic' ;
99
10- export interface RunSchematicTaskOptions {
11- collection : string ;
10+ export interface RunSchematicTaskOptions < T > {
11+ collection : string | null ;
1212 name : string ;
13- options : object ;
13+ options : T ;
1414}
Original file line number Diff line number Diff line change @@ -9,14 +9,27 @@ import { TaskConfiguration, TaskConfigurationGenerator } from '../../src';
99import { RunSchematicName , RunSchematicTaskOptions } from './options' ;
1010
1111
12- export class RunSchematicTask implements TaskConfigurationGenerator < RunSchematicTaskOptions > {
13- constructor (
14- protected _collection : string ,
15- protected _schematic : string ,
16- protected _options : object ,
17- ) { }
12+ export class RunSchematicTask < T > implements TaskConfigurationGenerator < RunSchematicTaskOptions < T > > {
13+ protected _collection : string | null ;
14+ protected _schematic : string ;
15+ protected _options : T ;
1816
19- toConfiguration ( ) : TaskConfiguration < RunSchematicTaskOptions > {
17+ constructor ( s : string , o : T ) ;
18+ constructor ( c : string , s : string , o : T ) ;
19+
20+ constructor ( c : string | null , s : string | T , o ?: T ) {
21+ if ( arguments . length == 2 || typeof s !== 'string' ) {
22+ o = s as T ;
23+ s = c as string ;
24+ c = null ;
25+ }
26+
27+ this . _collection = c ;
28+ this . _schematic = s as string ;
29+ this . _options = o as T ;
30+ }
31+
32+ toConfiguration ( ) : TaskConfiguration < RunSchematicTaskOptions < T > > {
2033 return {
2134 name : RunSchematicName ,
2235 options : {
You can’t perform that action at this time.
0 commit comments