@@ -69,8 +69,8 @@ export class TemplateGenerationCommand {
6969 if ( typeof this . configureSubcommand !== 'function' ) {
7070 throw new TypeError ( 'Cannot construct instance of TemplateGenerationCommand without overriding async method "configureSubcommand()"!' ) ;
7171 }
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"!' ) ;
7474 }
7575 // Set options controlling direct behavior
7676 this . program = program ;
@@ -89,6 +89,9 @@ export class TemplateGenerationCommand {
8989 * @param {option } options CLI runtime options
9090 */
9191 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.
9295 this . options = options ;
9396 this . name = name ;
9497 this . destination = destination ;
@@ -330,17 +333,17 @@ export class TemplateGenerationCommand {
330333 }
331334
332335 /**
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.
335338 *
336- * The default implementation allows for all files to be templated.
339+ * The default implementation always returns `true` - allowing all files to be templated.
337340 *
338341 * @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.
340343 */
341344 // eslint-disable-next-line no-unused-vars
342- filterByFileName ( filepath ) {
343- return false ;
345+ shouldTemplateFile ( filepath ) {
346+ return true ;
344347 }
345348
346349 /**
@@ -365,8 +368,8 @@ export class TemplateGenerationCommand {
365368 template : template . template ,
366369 } ;
367370 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 ) ) {
370373 buf = Buffer . from ( _ . template ( buf . toString ( ) , { interpolate : / { { ( [ \s \S ] + ?) } } / g } ) ( templateVars ) ) ;
371374 }
372375 const relPath = f . path . slice ( path . dirname ( template . template . path ) . length ) ;
0 commit comments