Permalink
Browse files

Merge branch 'master' of https://github.com/focusaurus/node-control

  • Loading branch information...
2 parents 463150d + 9ae5d59 commit a4f392a8d68de19fb60cd37f46535db5efd0e04b @tsmith committed Jan 27, 2012
Showing with 24 additions and 26 deletions.
  1. +6 −6 lib/configurator.js
  2. +5 −5 lib/index.js
  3. +8 −8 lib/log.js
  4. +5 −5 lib/task.js
  5. +0 −2 lib/timestamp.js
View
12 lib/configurator.js
@@ -1,6 +1,6 @@
/*global require, exports */
-var sys = require('sys'),
+var util = require('util'),
controller = require('./controller');
// Return a copy of a with prototype of b
@@ -15,11 +15,11 @@ function chain(a, b) {
}
function configure(prototype, address, options) {
- if (controller.prototype !== prototype &&
+ if (controller.prototype !== prototype &&
!controller.prototype.isPrototypeOf(prototype)) {
- throw new Error("Prototype is not a controller");
+ throw new Error("Prototype is not a controller");
}
-
+
if (!address) {
throw new Error("No address");
}
@@ -43,7 +43,7 @@ function controllers(addresses, prototype) {
prototype = controller.prototype;
}
- var list = [],
+ var list = [],
i, length, configured;
if (Array.prototype.isPrototypeOf(addresses)) {
for (i = 0, length = addresses.length; i < length; i += 1) {
@@ -63,7 +63,7 @@ function controllers(addresses, prototype) {
// deprecated
function hosts(config, addresses) {
- sys.puts("!! hosts() is deprecated");
+ util.puts("!! hosts() is deprecated");
if (!config) {
throw new Error("No config");
View
10 lib/index.js
@@ -3,16 +3,16 @@
var task = require('./task'),
controller = require('./controller'),
configurator = require('./configurator'),
- sys = require ('sys');
+ util = require ('util');
function begin() {
try {
task.begin();
} catch (e) {
- if (e.name === 'TypeError' && e.message ===
+ if (e.name === 'TypeError' && e.message ===
"Property 'log' of object #<Object> is not a function") {
- sys.puts('!! Set logPath instead of log on controllers.');
- }
+ util.puts('!! Set logPath instead of log on controllers.');
+ }
throw e;
}
}
@@ -22,4 +22,4 @@ exports.perform = task.perform;
exports.controller = controller.prototype;
exports.hosts = configurator.hosts;
exports.controllers = configurator.controllers;
-exports.begin = begin;
+exports.begin = begin;
View
16 lib/log.js
@@ -4,7 +4,7 @@
/*global require, exports */
-var sys = require('sys'),
+var util = require('util'),
fs = require('fs');
function createWriteStream(path) {
@@ -25,7 +25,7 @@ function puts(message, prefix, path) {
if (path && path !== this.path) {
this.path = path;
- filestream = this.filestream = createWriteStream(path);
+ filestream = this.filestream = createWriteStream(path);
}
// Message may contain leading, interstitial, or trailing carriage
@@ -37,31 +37,31 @@ function puts(message, prefix, path) {
// any group of new lines into one new line and then log each line with the
// timestamp and prefix. If you decide that all this trimming and
// indenting can be done more efficiently, please keep the carriage return
- // issue in mind.
+ // issue in mind.
message = message.replace(/\r/g, "\n"); // Carriage return conversion
message = message.replace(/^\n+|\n+$/g, ""); // Start and end clean up
- message = message.replace(/\n+/g, "\n"); // Group interstitial new lines
+ message = message.replace(/\n+/g, "\n"); // Group interstitial new lines
lines = message.split("\n");
for (i = 0, length = lines.length; i < length; i += 1) {
line = lines[i];
if (line.length > 0) { // Disregard empty lines
if (filestream) {
- filestream.write(timestamp.now() + ':' +
+ filestream.write(timestamp.now() + ':' +
logPrefix + line + '\n');
}
if (echo) {
- sys.puts(logPrefix + line);
+ util.puts(logPrefix + line);
}
}
}
}
// prefix: prefix that will be prefixed to every line of output
-// path: (optional) file path of persisted log
-// echo: (optional) true to echo to console, false otherwise
+// path: (optional) file path of persisted log
+// echo: (optional) true to echo to console, false otherwise
// timestamper: (optional) object that returns a timestamp from now() method
function Log(prefix, path, echo, timestamp) {
var filestream;
View
10 lib/task.js
@@ -1,6 +1,6 @@
/*global require, exports, process */
-var sys = require('sys');
+var util = require('util');
var tasks = {},
descriptions = {};
@@ -11,7 +11,7 @@ var tasks = {},
function shift(unshifted) {
var i, length, shifted = [];
for (i = 1, length = unshifted.length; i < length; i += 1) {
- shifted[i - 1] = unshifted[i];
+ shifted[i - 1] = unshifted[i];
}
return shifted;
}
@@ -28,7 +28,7 @@ function perform(name, config) {
log += " for " + config.id();
}
- sys.puts(log);
+ util.puts(log);
if (!task) {
throw new Error('No task named: ' + name);
@@ -43,7 +43,7 @@ function performAll(configs) {
}
var i, length, config,
- args = shift(arguments),
+ args = shift(arguments),
argsWithConfig;
for (i = 0, length = configs.length; i < length; i += 1) {
@@ -67,7 +67,7 @@ function task(name, description, callback) {
function list() {
for (var i in tasks) {
if (tasks.hasOwnProperty(i)) {
- sys.puts(i + ': ' + descriptions[i]);
+ util.puts(i + ': ' + descriptions[i]);
}
}
}
View
2 lib/timestamp.js
@@ -3,8 +3,6 @@
/*global require, exports */
-var sys = require('sys');
-
function padLeft(message, length) {
var delta, i;
message = message.toString();

0 comments on commit a4f392a

Please sign in to comment.