@@ -40,6 +40,14 @@ export class GeneratorService {
4040 const commands = flatten ( enabledGenerators . map ( ( [ name , config ] ) => {
4141 // eslint-disable-next-line @typescript-eslint/no-unused-vars
4242 const { glob : globPattern , disabled, ...params } = config
43+
44+ if ( ! globPattern ) {
45+ return [ {
46+ name : `[${ name } ] ${ params . inputSpec } ` ,
47+ command : this . buildCommand ( cwd , params )
48+ } ]
49+ }
50+
4351 const specFiles = glob . sync ( globPattern , { cwd} )
4452
4553 if ( specFiles . length < 1 ) {
@@ -48,7 +56,7 @@ export class GeneratorService {
4856
4957 return glob . sync ( globPattern , { cwd} ) . map ( spec => ( {
5058 name : `[${ name } ] ${ spec } ` ,
51- command : this . buildCommand ( cwd , spec , params ) ,
59+ command : this . buildCommand ( cwd , params , spec )
5260 } ) )
5361 } ) )
5462
@@ -77,11 +85,11 @@ export class GeneratorService {
7785 } ) . join ( '\n' ) )
7886 }
7987
80- private buildCommand ( cwd : string , specFile : string , params : Record < string , unknown > ) {
81- const absoluteSpecPath = path . resolve ( cwd , specFile )
88+ private buildCommand ( cwd : string , params : Record < string , unknown > , specFile ?: string ) {
89+ const absoluteSpecPath = specFile ? path . resolve ( cwd , specFile ) : String ( params . inputSpec )
8290
8391 const command = Object . entries ( {
84- [ 'input-spec' ] : absoluteSpecPath ,
92+ inputSpec : absoluteSpecPath ,
8593 ...params ,
8694 } ) . map ( ( [ k , v ] ) => {
8795
@@ -113,17 +121,19 @@ export class GeneratorService {
113121 cwd,
114122
115123 base : path . basename ( absoluteSpecPath ) ,
116- dir : path . dirname ( absoluteSpecPath ) ,
124+ dir : specFile && path . dirname ( absoluteSpecPath ) ,
117125 path : absoluteSpecPath ,
118126
119- relDir : path . dirname ( specFile ) ,
127+ relDir : specFile && path . dirname ( specFile ) ,
120128 relPath : specFile ,
121- ext : ext . split ( '.' ) . slice ( - 1 ) . pop ( ) ,
129+ ext : ext . split ( '.' ) . slice ( - 1 ) . pop ( )
122130 }
123131
124- return this . cmd ( Object . entries ( placeholders ) . reduce ( ( cmd , [ search , replacement ] ) => {
125- return cmd . split ( `#{${ search } }` ) . join ( replacement )
126- } , command ) )
132+ return this . cmd ( Object . entries ( placeholders )
133+ . filter ( ( [ , replacement ] ) => ! ! replacement )
134+ . reduce ( ( cmd , [ search , replacement ] ) => {
135+ return cmd . split ( `#{${ search } }` ) . join ( replacement )
136+ } , command ) )
127137 }
128138
129139 private cmd = ( appendix : string ) => [
0 commit comments