thanpolas/task-closure-tools — pull request #9 by betaorbust (2014-12-06 08:42:52+00:00)
Title: Fix silent compiler hang on empty src

This PR addresses https://github.com/thanpolas/grunt-closure-tools/issues/67 which was initially incorrectly reported in that repo.

#### Summary of issue
When there are no src files provided to `libCompiler.js:compiler.compileCommand` the generated command breaks Closure Compiler with a silent hang.
#### Expected behavior
If no src files are provided, a blank file is created at the provided destination.

#### Work in this PR
- Fixes silent compiler hang when `src` files are empty by not invoking Closure Compiler in this case.
- Implements default empty `src` behavior: blank file written to `dest`.
- Adds unit tests for empty `src` activity.

To keep the paradigm and separation of "build commands in `libCompiler.js`, execute commands in `helpers.js`" that was already going on, the following modifications were made:
- `libCompiler.js:compiler.compileCommand` now detects empty src, and generates a new type of command -- an object instead of a string -- that can be used for new, non-shell-script command types going forward.
- `helpers.js:helpers.executeCommand` now handles the new command types, and has a case for the new empty command.

#### Notes
New functionality is exclusively in `lib/helpers.js` and `lib/libCompiler.js`. The rest is just tests etc. Did not see a `CHANGELOG.md` file as mentioned in `CONTRIBUTING` but happy to add to it if I just missed it.

![](http://38.media.tumblr.com/tumblr_lrd6l5OI1D1qa0v77o1_500.gif)