(root)
| 14 | |
| 15 | // Since our current development pattern uses npm as its package repository, we treat the nearest ancestor directory with a package.json (inclusive) as the directory's "root". |
| 16 | function findRoot(root) { |
| 17 | var pkg; |
| 18 | root = root.split(path.sep); |
| 19 | while(!pkg && root.length > 1) { |
| 20 | var cur = root.join(path.sep); |
| 21 | if(fs.existsSync(path.join(cur, "package.json"))) { |
| 22 | return cur; |
| 23 | } |
| 24 | root.pop(); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | |
| 29 | var port = argv["port"] || process.env.PORT || 8080; |