Created
January 11, 2012 18:43
-
-
Save munro/1596121 to your computer and use it in GitHub Desktop.
Auto Restart Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Auto restart server on file changes | |
(function () { | |
var fs = require('fs'), | |
original = require.extensions['.js']; | |
function exitOnChange(filename) { | |
fs.watchFile(filename, function (curr, prev) { | |
if (curr.mtime !== prev.mtime) { | |
process.exit(); | |
} | |
}); | |
} | |
require.extensions['.js'] = function (options) { | |
exitOnChange(options.filename); | |
original.apply(this, arguments); | |
}; | |
exitOnChange(require.main.filename); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
while [ True ]; do npm start; done