trek/grunt-neuter — pull request #46 by AndreasPizsa (2013-12-29 20:23:49+00:00)
Title: Fail when required file is missing. Fixes #45

I've had the situation where I accidently `require()`d a missing file. The app built fine, but then didn't run.

It took me a while to figure out why my app wasn't working until I found out that neuter silently ignored the missing file, concatenated the remaining ones and continued with the build. (I was using an older version of neuter that didn't warn about missing files as it was only checking for `!files` and not `!files.length`, but I see that's changed now). At runtime, of course, everything form the missing file was missing in the code and caused errors.

I think the expected behaviour is the following:
- `require()` means that something is _required_ for a build
- wildcard names can resolve to zero or more files. So zero is ok, but probably worth knowing about.
- requiring a specific file means that file is required. If it's missing, there is something seriously wrong.

I fixed this the following way:

If `glob` returns zero files and `require()` was called with...
- ... a wildcard character: issue a warning and continue with the build (`grunt.log.warn`)
- ... with a specific file name (no wildcards): issue a warning and fail (`grunt.fail.warn`).

Thanks :)