Permalink
Browse files

Fix issue # 90: `supervisor file.js` might hang

If the global `node_modules` directory is in a symlinked path
`process.argv[1]` and `__filename` might differ, despite the fact that
they are pointing to the same file.

This commit normalizes `process.argv[1]` to its "realpath" before
checking for its equivalence to `__filename`.

This commit assumes `__filename` has already been normalized to its
realpath by node. If this is not true, `__filename` will need to be
normalized as well.

Note: This has been tested on Windows 7 only.
  • Loading branch information...
1 parent c87c08d commit c0cdb87369533cec970ed02b432f8bb415e027b7 @davidmurdoch davidmurdoch committed Feb 12, 2013
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/cli-wrapper.js
View
@@ -1,10 +1,11 @@
#!/usr/bin/env node
var path = require("path")
+ , fs = require("fs")
, args = process.argv.slice(1)
var arg, base;
do arg = args.shift();
-while ( arg !== __filename
+while ( fs.realpathSync(arg) !== __filename
&& (base = path.basename(arg)) !== "node-supervisor"
&& base !== "supervisor"
&& base !== "supervisor.js"

0 comments on commit c0cdb87

Please sign in to comment.