0.0.4 • Published 11 years ago
proctor v0.0.4
proctor
~ Watch over your javascripts.
Proctor lets you watch over your javascript file with a function as an export. For instance(and as a real-world example), I can have a server file like this:
// server.js
var http = require('http');
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello, World!\n');
});
exports.startServer = function (config) {
server.listen(config.port);
console.log('Server running at ' + config.port);
};
Notice that this file only exports a startServer
function,
so it is impossible to develop with something like forever
.
Instead, I can use Proctor:
// run.js
var Proctor = require('proctor');
var runner = new Proctor({
file: 'server.js',
fn: 'startServer',
restart: true,
config: {
port: 3333
}
});
runner.start();
Now when I run node run.js
, Proctor will spin up a separate child process in which to run my file,
and reload it automatically when it is changed.
This is perfect for build system support, especially if you're developing a web app.