Skip to content

Commit

Permalink
Update generator to support underscores in template filename extensions.
Browse files Browse the repository at this point in the history
This is to support cases such as Go where the compiler looks for all .go
files in the directory and reports functions and variables as redeclared
because they exist in both the template and generated file.
  • Loading branch information
F21 committed Oct 14, 2019
1 parent 00f7d25 commit 988314c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ Generator.getTemplatesSync = function () {

Generator.parsePath = function (fullpath) {
var dir = p.dirname(fullpath);
var output = p.basename(fullpath).replace('.tmpl', '');
var output = p.basename(fullpath).replace('.tmpl', '').replace(/(_)/g, function (match, _, offset, string) {
return offset > string.lastIndexOf('.') ? '' : '_';
});
return {
fullpath: fullpath,
fullOutputPath: p.resolve(dir, output),
Expand Down

0 comments on commit 988314c

Please sign in to comment.