ericclemmons / ericclemmons/grunt-angular-templates

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

Open
#74 2 comments 0 reactions 1 assignee Claimed by @ericclemmons View on GitHub
Dominant language
JavaScript
Stars
705
Forks
107
PR merge metrics
No merged PRs in 30d

Description

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:

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

running grunt:

```
$ grunt --verbose ngtemplates
...
Reading ...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)

``` js
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.