ericclemmons / grunt-angular-templates

Grunt build task to concatenate & pre-load your AngularJS templates
MIT License
710 stars 107 forks source link

silent failure with unhelpful message if "dest" is not a string (e.g. an array) #74

Open robdennis opened 10 years ago

robdennis commented 10 years ago

let me preface this by saying it's completely my own fault, but I lost a fair bit of time looking at my configuration before realizing my problem (since at a glance it appeared my configuration matched the examples).

consider this ngtemplates configuration:

        //ng-templates
        ngtemplates: {
            app: {
                src: ['assets/views/*.html'],
                dest: ['template.js']
            }

running grunt:

$ grunt --verbose ngtemplates
...
Reading <my templates>...OK
Writing template.js...ERROR
Warning: Unable to write "template.js" file (Error code: undefined). Use --force to continue.

Aborted due to warnings.

this is an unhelpful error emitted from grunt's file.write function (which you us) and after some digging I realized that the real error was "TypeError: path must be a string" and that clued me into my mistake.

I might have expected an error message pointing out that dest had to be a string. Further the fact that it says:

Writing template.js

vs

Writing [ 'template.js' ]

Allowed me to think I was providing good data. (this is from this line from grunt.file.write)

grunt.verbose.write((nowrite ? 'Not actually writing ' : 'Writing ') + filepath + '...');

This is on version 0.5.1

edit: pointing out another thing where grunt's logging steered me wrong

ericclemmons commented 10 years ago

Good point. Not really a fan of Grunt in particular because of the whole "here's 1 of 600 ways to define your files", but this is a good point.

robdennis commented 10 years ago

Cool. Thanks for the quick response and for the project.