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

Commit ff399cb

Browse files
committed
Rename method name and update coumment
1 parent bdb0e02 commit ff399cb

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/commands/pipelines.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ export const PipelineGenerateCommand = class extends TemplateGenerationCommand {
278278
super(program, 'Pipeline', 'pipelines', 'pipelinename', 'pipelineTemplateConfig');
279279
}
280280

281-
// TODO: Need a better way to handle this filtering
282-
filterByFileName(filepath) {
281+
shouldTemplateFile(filepath) {
283282
// NOTE: It is common for dbt's templating (jinja2?) to collide with Lodash's templating syntax.
284283
// Current workaround is to exclude DBT & SQL files from templating, only downside is that those
285284
// can't use the {{pipelinename}} variable.

src/commands/workspaces/generate.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)