isaacs/node-supervisor — Issue #49: Arguments are passed incorrectly when using coffee script
Author: szimek
Created: 2012-03-08 19:36:34+00:00
State: open

Hi,

there's the following code in [supervisor.js#155](https://github.com/isaacs/node-supervisor/blob/master/lib/supervisor.js#L155):

```javascript
var spawnme = args ? [prog].concat(args) : [prog];
```

The issue with it is that coffee script expects options first and then script name:

```
$ coffee --help
Usage: coffee [options] path/to/script.coffee
```

while the script above provides script name first (`prog`) and then options (`args`).

Changing the line above to:

```javascript
var spawnme = args ? args.concat[prog] : [prog];
```

solves the issue and allows to run node js with debugger enabled like this:

`supervisor -- app.coffee --nodejs --debug`

If the order in which script name and arguments should be passed depends on executable, maybe it would be possible to add an option for that (e.g. `--options-first`), which for `coffee` would be set by default.

I can prepare a patch for that if anybody else thinks it's a good idea :)