From 103126a8b73029ca48803f84a11f2ec192103574 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 2 Nov 2010 09:19:27 -0700 Subject: [PATCH] Detect for 'util', and use it if it's there. Otherwise fall back to 'sys'. This is the recommended check by isaacs. --- bin/spark | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/spark b/bin/spark index 0ffa34a..23fde3a 100755 --- a/bin/spark +++ b/bin/spark @@ -15,7 +15,7 @@ var child_process = require('child_process'), dirname = require('path').dirname, exists = require('path').existsSync, http = require('http'), - sys = require('sys'), + util = require(process.binding('natives').util ? 'util' : 'sys'), fs = require('fs'), cwd = process.cwd(), net = require('net'); @@ -96,7 +96,7 @@ var usage = '' */ function log(msg) { - if (verbose) sys.error('... ' + colorize(msg)); + if (verbose) util.error('... ' + colorize(msg)); } /** @@ -168,7 +168,7 @@ function modulePath(path){ */ function abort(msg, code) { - sys.error(colorize(msg)); + util.error(colorize(msg)); process.exit(code || 1); } @@ -193,7 +193,7 @@ function loadConfig(file) { // Apply flags val.forEach(function(val){ - log(' ' + key + ' ' + (val === true ? '' : sys.inspect(val))); + log(' ' + key + ' ' + (val === true ? '' : util.inspect(val))); args.push(key); if (typeof val !== 'boolean') { args.push(val); @@ -299,7 +299,7 @@ function startWorker() { }); stdin.addListener('fd', function(fd){ var app = requireApp(getAppPath()); - sys.error('Spark server(' + process.pid + ') listening on ' + util.error('Spark server(' + process.pid + ') listening on ' + 'http' + (env.sslKey ? 's' : '') + '://' + (env.host || '*') + ':' + env.port + ' in ' + env.name + ' mode'); @@ -389,7 +389,7 @@ function start() { // Load the app module var app = requireApp(path); - sys.error('Spark server(' + process.pid + ') listening on ' + util.error('Spark server(' + process.pid + ') listening on ' + 'http' + (env.sslKey ? 's' : '') + '://' + (env.host || '*') + ':' + env.port + ' in ' + env.name + ' mode');