Skip to content

Commit

Permalink
Replaces references to the 'sys' module with 'util'.
Browse files Browse the repository at this point in the history
  • Loading branch information
atourino committed Nov 10, 2011
1 parent ed18c24 commit b9f4471
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/supervisor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var sys = require("sys");
var util = require("util");
var fs = require("fs");
var spawn = require("child_process").spawn;
var fileExtensionPattern;
Expand Down Expand Up @@ -44,13 +44,13 @@ function run (args) {
executor = (programExt === "coffee") ? "coffee" : "node";
}

sys.puts("")
sys.debug("Running node-supervisor with");
sys.debug(" program '" + program + "'");
sys.debug(" --watch '" + watch + "'");
sys.debug(" --extensions '" + extensions + "'");
sys.debug(" --exec '" + executor + "'");
sys.puts("")
util.puts("")
util.debug("Running node-supervisor with");
util.debug(" program '" + program + "'");
util.debug(" --watch '" + watch + "'");
util.debug(" --extensions '" + extensions + "'");
util.debug(" --exec '" + executor + "'");
util.puts("")

// if we have a program, then run it, and restart when it crashes.
// if we have a watch folder, then watch the folder for changes and restart the prog
Expand All @@ -61,12 +61,12 @@ function run (args) {
// convert watch item to absolute path
watchItem = process.cwd() + '/' + watchItem;
}
sys.debug("Watching directory '" + watchItem + "' for changes.");
util.debug("Watching directory '" + watchItem + "' for changes.");
findAllWatchFiles(watchItem, watchGivenFile);
});
};

function print (m, n) { sys.print(m+(!n?"\n":"")); return print }
function print (m, n) { util.print(m+(!n?"\n":"")); return print }

function help () {
print
Expand Down Expand Up @@ -108,10 +108,10 @@ function help () {
}

function startProgram (prog, exec) {
sys.debug("Starting child process with '" + exec + " " + prog + "'");
util.debug("Starting child process with '" + exec + " " + prog + "'");
var child = exports.child = spawn(exec, [prog]);
child.stdout.addListener("data", function (chunk) { chunk && sys.print(chunk) });
child.stderr.addListener("data", function (chunk) { chunk && sys.debug(chunk) });
child.stdout.addListener("data", function (chunk) { chunk && util.print(chunk) });
child.stderr.addListener("data", function (chunk) { chunk && util.debug(chunk) });
child.addListener("exit", function () { startProgram(prog, exec) });
}

Expand All @@ -129,7 +129,7 @@ function crash (oldStat, newStat) {
counter ++;

var child = exports.child;
sys.debug("crashing child");
util.debug("crashing child");
process.kill(child.pid);
}

Expand All @@ -145,12 +145,12 @@ function watchGivenFile (watch) {
var findAllWatchFiles = function(path, callback) {
fs.stat(path, function(err, stats){
if (err) {
sys.error('Error retrieving stats for file: ' + path);
util.error('Error retrieving stats for file: ' + path);
} else {
if (stats.isDirectory()) {
fs.readdir(path, function(err, fileNames) {
if(err) {
sys.puts('Error reading path: ' + path);
util.puts('Error reading path: ' + path);
}
else {
fileNames.forEach(function (fileName) {
Expand Down

0 comments on commit b9f4471

Please sign in to comment.