@@ -69,8 +69,8 @@ export class TemplateGenerationCommand {
69
69
if ( typeof this . configureSubcommand !== 'function' ) {
70
70
throw new TypeError ( 'Cannot construct instance of TemplateGenerationCommand without overriding async method "configureSubcommand()"!' ) ;
71
71
}
72
- if ( typeof this . filterByFileName !== 'function' ) {
73
- throw new TypeError ( 'Cannot construct instance of TemplateGenerationCommand without overriding async method "filterByFileName (string) -> bool"!' ) ;
72
+ if ( typeof this . shouldTemplateFile !== 'function' ) {
73
+ throw new TypeError ( 'Cannot construct instance of TemplateGenerationCommand without overriding async method "shouldTemplateFile (string) -> bool"!' ) ;
74
74
}
75
75
// Set options controlling direct behavior
76
76
this . program = program ;
@@ -89,6 +89,9 @@ export class TemplateGenerationCommand {
89
89
* @param {option } options CLI runtime options
90
90
*/
91
91
async init ( name , destination , options ) {
92
+ // NOTE: The code originally assigned below properties across multiple methods, which
93
+ // made keeping track of properties difficult. These assignments have been grouped
94
+ // together in a single method for simplicity.
92
95
this . options = options ;
93
96
this . name = name ;
94
97
this . destination = destination ;
@@ -330,17 +333,17 @@ export class TemplateGenerationCommand {
330
333
}
331
334
332
335
/**
333
- * Returns whether a given file (path) in the template should be excluded from the template .
334
- * Should return `true ` if the file should be copied without modification.
336
+ * Returns whether a given file (path) should have templating applied to it .
337
+ * Should return `false ` if the file should be copied without modification.
335
338
*
336
- * The default implementation allows for all files to be templated.
339
+ * The default implementation always returns `true` - allowing all files to be templated.
337
340
*
338
341
* @param {string } filepath
339
- * @returns {boolean } true if the file should NOT be templated, false otherwise
342
+ * @returns {boolean } true if the file should be templated, false otherwise.
340
343
*/
341
344
// eslint-disable-next-line no-unused-vars
342
- filterByFileName ( filepath ) {
343
- return false ;
345
+ shouldTemplateFile ( filepath ) {
346
+ return true ;
344
347
}
345
348
346
349
/**
@@ -365,8 +368,8 @@ export class TemplateGenerationCommand {
365
368
template : template . template ,
366
369
} ;
367
370
let buf = await this . readFile ( f . path ) ;
368
- /// Try not to template any non-text files, and allow for a filter
369
- if ( isText ( null , buf ) && ! this . filterByFileName ( f . path ) ) {
371
+ /// Try not to template any non-text files and allow filering based on file names
372
+ if ( isText ( null , buf ) && this . shouldTemplateFile ( f . path ) ) {
370
373
buf = Buffer . from ( _ . template ( buf . toString ( ) , { interpolate : / { { ( [ \s \S ] + ?) } } / g } ) ( templateVars ) ) ;
371
374
}
372
375
const relPath = f . path . slice ( path . dirname ( template . template . path ) . length ) ;
0 commit comments