miickel / gulp-angular-templatecache

Concatenates and registers AngularJS templates in the $templateCache.
MIT License
524 stars 103 forks source link

Crash with a cryptic error message when a folder container a dot #145

Closed thib-rdr closed 5 years ago

thib-rdr commented 7 years ago

Hi all,

When using angularTemplatecache() to concatenate all my templates to a template.js file, it crashes when a folder with a dot is present in the project.

TypeError: Cannot read property 'toString' of null at templateCacheFile (path/node_modules/gulp-angular-templatecache/index.js:89:36) at wrappedMapper (path/node_modules/event-stream/node_modules/map-stream/index.js:84:19) Thanks !

simonua commented 6 years ago

Hi @thib-rdr, is this issue still relevant? If so, could you create a PR to address this, please? If not, could you close the issue, please?

simonua commented 5 years ago

I was not able to recreate this problem with a folder with a dot in its name that contained a template. gulp-angular-templatecache did not crash and produced this expected output:

angular.module("app").run(["$templateCache",function(t){t.put("app/testfolder.withdot/simontemplate.html","<p>This is a template by simon</p>")

simonua commented 5 years ago

Closing this issue due to age of issue and failure to recreate. Perhaps a fix was already done or a dependency that caused this was updated in the meantime. If this issue persists, please add full STRs and sample when reopening.

ashclarke commented 5 years ago

I just recreated this problem by accident:

components
|
--- news-item-title.tpl.html
     |
     --- news-item-title.tpl.html

I'd accidentally named my folder with the same convention, and in this case exactly the same name, as my template files.

Hope it helps!

simonua commented 5 years ago

@ashclarke, thanks for the repro. I'm trying to weigh how much of a use-case a folder with a dot may be. It's perhaps not unusual but I'm struggling to determine whether it's more than an edge case. I'd love to review a PR if you have time and inclination to dive further into it.

ashclarke commented 5 years ago

No worries. Wouldn’t mind looking into it - might be able to have a bash at the weekend.

simonua commented 5 years ago

@ashclarke, that would be very appreciated. No rush. Just happy to hear willingness to contribute. If you do end up getting into it, could you please add appropriate tests, too?

Thank you very much!

the-ress commented 5 years ago

This happens when the gulp.src glob matches a directory. This can happen with templates/**/*.html and a directory ending with .html or with templates/** and any directory.

simonua commented 5 years ago

Fixed by PR #171.