Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 400cfeb130
Fetching contributors…

Cannot retrieve contributors at this time

executable file 44 lines (36 sloc) 0.911 kb
#! /usr/bin/env node
var spawn = require('child_process').spawn
, fs = require('fs')
, env = process.env
, node = process.argv[0]
// Pass the location of the node-dev script to the child process
env.NODE_DEV = process.argv[1]
var args = process.argv.slice(2)
if (!args.length) {
try {
args.push(JSON.parse(fs.readFileSync('./package.json', 'utf8')).main)
}
catch (err) {
console.log('Usage: node-dev [options] script.js [arguments]\n')
process.exit(1)
}
}
// Find the first arg that is not an option
for (var i=0; i < args.length; i++) {
if (!/^-/.test(args[i])) {
args.splice(i, 0, __dirname + '/wrapper.js')
break
}
}
function start() {
var child = spawn(node, args, {
cwd: process.cwd(),
env: env,
customFds: [0, 1, 2]
})
child.on('exit', function(code) {
if (code === 101) process.nextTick(start)
else process.exit(code)
})
}
start()
Jump to Line
Something went wrong with that request. Please try again.