Skip to content

Commit

Permalink
Move requiring util to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Nov 30, 2010
1 parent 12d2aeb commit 88711fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
9 changes: 1 addition & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
/*global Buffer require exports console setTimeout */

var net = require("net"),
util,
util = require("./lib/util").util,
events = require("events"),
default_port = 6379,
default_host = "127.0.0.1";

// hilarious 0.2.x to 0.3.x API change
try {
util = require("util");
} catch (err) {
util = require("sys");
}

// can can set this to true to enable for all connections
exports.debug_mode = false;

Expand Down
7 changes: 7 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if (process.versions.node.match(/^0.3/)) {
exports.util = require("util");
} else {
/* This module is called "sys" in 0.2.x */
exports.util = require("sys");
}

8 changes: 1 addition & 7 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ var redis = require("./index"),
client2 = redis.createClient(),
client3 = redis.createClient(),
assert = require("assert"),
util,
util = require("./lib/util").util,
test_db_num = 15, // this DB will be flushed and used for testing
tests = {},
connected = false,
ended = false,
server_info;

try {
util = require("util");
} catch (err) {
util = require("sys");
}

// Uncomment this to see the wire protocol and other debugging info
//redis.debug_mode = true;

Expand Down

0 comments on commit 88711fe

Please sign in to comment.