Skip to content

Nodemon now sends arguments to the executable in the right order #55

wants to merge 1 commit into from

3 participants

Hubro commented Jan 15, 2012

Fixed the problem I mentioned in this issue


This fix will break the ordering of arguments the the script itself though, won't it? Since appargs is being reversed, the node args will work and the scripts args will be backwards.

I propose collecting the exec arguments in their own list, and concatenating that with the script args after the arg iteration.

diff --git a/nodemon.js b/nodemon.js
index ff01d41..6857e8d 100755
--- a/nodemon.js
+++ b/nodemon.js
@@ -214,6 +214,7 @@ function getNodemonArgs() {
   var appargs = process.argv.slice(indexOfApp),
       app = appargs[0],
       nodemonargs = process.argv.slice(2, indexOfApp),
+      execargs = [],
       options = {
         delay: 1,
@@ -248,10 +249,12 @@ function getNodemonArgs() {
       options.exec = nodemonargs.shift();
     } else { //if (arg === "--") {
       // Remaining args are node arguments
-      appargs.unshift(arg);
+      execargs.push(arg);

+  appargs = execargs.concat(appargs);
   var program = { nodemon: nodemonargs, options: options, args: appargs, app: app };

remy commented Jan 15, 2012

The problem is: exec only takes one argument. If you intend to send more argument to exec, how is nodemon supposed to know when you've finished?

This means that exec would have to come last - but before the script, and that to me seems wrong (though I'm not saying this --debug bug shouldn't be fixed - it was working, but my recent refactor has broken it). I'm going to do two changes:

  1. Fix the --debug with coffeescript (also support --debug-brk) so that you can run nodemon --debug and it gets the args right.
  2. Support quoting the exec: nodemon -x "coffee --nodejs" - that way the ordering of the exec doesn't matter.

I'll post here when both changes are in npm.

@remy remy closed this Jan 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.