cri5ti/grunt-shell-spawn — pull request #18 by sergkr (2014-02-09 20:32:47+00:00)
Title: Fix the :kill task on Unix and Windows (#14)

This fixes issue #14, and depends on PR #17.

The basic idea is:

- On Unix, we kill the entire process group by passing in a negative PID to `process.kill()`
- On Windows, we kill the entire process tree by passing in the `/T` option to `TaskKill.exe`.

I updated tests with relevant test cases (essentially runs the killTask twice and makes sure that it didn't error out the second time, which would indicate the previous server instance is still running). I also fixed the tests so you can run them on both Windows and Unix (using `npm test`), which really just boiled down to using `path.normalize()` to get the grunt executable path.

**I'm not able to test this on Mac OS X.** I'm assuming things ought to work the same as under Unix, but I don't have a Mac that I could test this on. If someone is able to test this on a Mac, please check if running `npm test` (preferably twice, just to make sure) reports any errors and let me know.

Note there's one significant downside to the approach I'm taking here, which is that by default, async processes will continue running even after grunt finishes, unless explicitly killed using `:kill`. This is because of the `{ detached: true }` option, which is now set to true. I updated the readme with this information under the "Killing an async process" section... though maybe I should call it out even more. Let me know what you think.