Permalink
Browse files

sys was replaced by util in nodejs

  • Loading branch information...
1 parent aa0bd14 commit 3f1a69c5cf268498919e5d406c770f6bd112e828 @dimvar dimvar committed Sep 7, 2011
Showing with 36 additions and 41 deletions.
  1. +11 −11 bin/dr.js
  2. +14 −14 bin/jsctags.js
  3. +3 −3 bin/rn.js
  4. +1 −1 js/tiki.js
  5. +2 −2 lib/formidable/incoming_form.js
  6. +0 −2 lib/jsctags/ctags/nativefn.js
  7. +0 −2 lib/jsctags/getopt.js
  8. +2 −2 lib/jsctags/log.js
  9. +0 −1 lib/jsctags/paperboy.js
  10. +1 −1 serve.js
  11. +2 −2 test/readtags.js
View
@@ -44,20 +44,20 @@ var libdir = path.join(cwd, "..", "lib");
require.paths.unshift(path.join(libdir, "jsctags"));
-var sys = require('sys');
+var util = require('util');
var _ = require('underscore')._;
var http = require('http');
var url = require('url');
var servetypes = require('servetypes');
function usage(msg) {
- sys.print("usage: " + path.basename(argv[1]) + " [options]\n");
- sys.print(" -h/--help Print usage information\n");
- sys.print(" -s/--static Directory containing static web content\n");
- sys.print(" -n/--no-service Disable the JSON service");
- sys.print(" -p/--port Server port to listen on\n");
+ util.print("usage: " + path.basename(argv[1]) + " [options]\n");
+ util.print(" -h/--help Print usage information\n");
+ util.print(" -s/--static Directory containing static web content\n");
+ util.print(" -n/--no-service Disable the JSON service");
+ util.print(" -p/--port Server port to listen on\n");
if (msg) {
- sys.print("\n" + msg + "\n");
+ util.print("\n" + msg + "\n");
process.exit(1);
}
@@ -152,7 +152,7 @@ function makeSiteHandler(dir, service) {
var fs = require('fs');
fs.stat(file, function(err, stats) {
if (!stats || !stats.isFile()) {
- sys.debug("404: " + file);
+ util.debug("404: " + file);
resp.writeHead(404, "Not Found", { 'Content-type': 'text/plain' });
resp.end("404 Not Found");
return;
@@ -189,13 +189,13 @@ parseOpts(argv.slice(2), function(err, opts) {
var handler;
if (opts.dir) {
- sys.log("staging site from " + opts.dir);
+ util.log("staging site from " + opts.dir);
handler = makeSiteHandler(opts.dir, opts.service);
} else {
- sys.log("running JSON service only");
+ util.log("running JSON service only");
handler = service;
}
- sys.log("listening on port " + opts.port + "...");
+ util.log("listening on port " + opts.port + "...");
http.createServer(handler).listen(opts.port, "127.0.0.1");
});
View
@@ -41,24 +41,24 @@ var path = require('path');
var _ = require('underscore')._;
var fs = require('fs');
-var sys = require('sys');
+var util = require('util');
var ctags = require('ctags');
var getopt = require('getopt').getopt;
var log = require('log');
var Tags = ctags.Tags;
function usage() {
- sys.puts("usage: jsctags [options] path0 [.. pathN]");
- sys.puts("options:");
- sys.puts(" -f, --output file place output in the given file (-f " +
+ util.puts("usage: jsctags [options] path0 [.. pathN]");
+ util.puts("options:");
+ util.puts(" -f, --output file place output in the given file (-f " +
"- for stdout)");
- sys.puts(" -h, --help display this usage info");
- sys.puts(" -j, --jsonp function use JSONP with a function name");
- sys.puts(" -o, --output file synonym for -f");
- sys.puts(" --oneprog combine all inputs into one program");
- sys.puts(" -L, --libroot dir add a CommonJS module root (like " +
+ util.puts(" -h, --help display this usage info");
+ util.puts(" -j, --jsonp function use JSONP with a function name");
+ util.puts(" -o, --output file synonym for -f");
+ util.puts(" --oneprog combine all inputs into one program");
+ util.puts(" -L, --libroot dir add a CommonJS module root (like " +
"require.paths)")
- sys.puts(" -W, --warning level set log level (debug/info/warn/" +
+ util.puts(" -W, --warning level set log level (debug/info/warn/" +
"error, default error)");
process.exit(1);
}
@@ -68,7 +68,7 @@ try {
opts = getopt("help|h", "jsonp|j=s", "libroot|L=s@", "oneprog", "output|o|f=s",
"sort|=s", "warning|W=s");
} catch (e) {
- sys.puts(e);
+ util.puts(e);
usage();
}
@@ -80,7 +80,7 @@ if (opts.help || pathCount === 0) {
if (opts.warning) {
var level = opts.warning.toUpperCase();
if (!log.levels.hasOwnProperty(level)) {
- sys.puts("no such logging level: \"" + opts.warning + "\"");
+ util.puts("no such logging level: \"" + opts.warning + "\"");
usage();
}
log.level = log.levels[level];
@@ -189,9 +189,9 @@ function processPath(p) {
tags.scan(data, p, getModuleInfo(p));
} catch (e) {
if ('lineNumber' in e) {
- sys.puts("error:" + p + ":" + e.lineNumber + ": " + e);
+ util.puts("error:" + p + ":" + e.lineNumber + ": " + e);
} else {
- sys.puts(e.message);
+ util.puts(e.message);
throw e;
}
}
View
@@ -44,7 +44,7 @@ var libdir = path.join(cwd, "..", "lib");
require.paths.unshift(path.join(libdir, "jsctags"));
-var sys = require('sys');
+var util = require('util');
var _ = require('underscore')._;
var getTags = require('../lib/cfa2/jscfa').getTags;
var parse = require('../narcissus/lib/parser').parse;
@@ -62,7 +62,7 @@ stdin.on("end", function() {
lines = src.split("\n");
ast = parse(src, "js", 1);
} catch (e) {
- sys.print(JSON.stringify({ error: e.message, stage: "parse" }));
+ util.print(JSON.stringify({ error: e.message, stage: "parse" }));
process.exit();
}
@@ -73,6 +73,6 @@ stdin.on("end", function() {
json = { error: e.message, stage: "analysis" };
}
- sys.print(JSON.stringify(json));
+ util.print(JSON.stringify(json));
process.exit();
});
View
@@ -166,7 +166,7 @@ var DEBUG = function() {
exports.debug = function() {
var msg = Array.prototype.join.call(arguments, '');
- require('sys').debug(msg);
+ require('util').debug(msg);
};
// ..........................................................
@@ -1,6 +1,6 @@
if (global.GENTLY) require = GENTLY.hijack(require);
-var sys = require('sys')
+var util = require('util')
, path = require('path')
, WriteStream = require('fs').WriteStream
, MultipartParser = require('./multipart_parser').MultipartParser
@@ -28,7 +28,7 @@ function IncomingForm() {
this._flushing = 0;
this._fieldsSize = 0;
};
-sys.inherits(IncomingForm, EventEmitter);
+util.inherits(IncomingForm, EventEmitter);
exports.IncomingForm = IncomingForm;
IncomingForm.prototype.parse = function(req, cb) {
@@ -38,8 +38,6 @@
// Functions important for export detection that that we try to automatically
// detect and implement.
-var sys = require('sys');
-
// jQuery's "extend".
function extend(interp, ctx, thisObject, args) {
var objects = args.data.slice(0);
@@ -40,8 +40,6 @@
* Getopt::Long.
*/
-var sys = require('sys');
-
exports.getopt = exports.GetOptions = function() {
var table = {};
for (var i = 0; i < arguments.length; i++) {
View
@@ -35,11 +35,11 @@
*
* ***** END LICENSE BLOCK ***** */
-var sys = require('sys');
+var util = require('util');
function log(level, args) {
if (level >= exports.level) {
- sys.puts(Array.prototype.join.call(args, " "));
+ util.puts(Array.prototype.join.call(args, " "));
}
}
@@ -1,5 +1,4 @@
var
- sys = require('sys'),
events = require('events'),
fs = require('fs'),
url = require('url'),
View
@@ -38,7 +38,7 @@
require.paths.unshift('./lib/jsctags');
var http = require('http'), paperboy = require('paperboy');
-var sys = require('sys');
+var util = require('util');
http.createServer(function(req, resp) {
paperboy.deliver(__dirname, req, resp).
View
@@ -5,12 +5,12 @@ var path = require('path');
require.paths.unshift(path.join(path.dirname(argv[1]), "..", "lib",
"jsctags"));
-var ctags = require('ctags'), fs = require('fs'), sys = require('sys');
+var ctags = require('ctags'), fs = require('fs'), util = require('util');
var tags = new ctags.Tags();
var str = fs.readFileSync(argv[2]);
tags.readString(str);
var result = (argv.length >= 4) ? tags.stem(argv[3]) : tags.tags;
-sys.puts(sys.inspect(result));
+util.puts(util.inspect(result));

0 comments on commit 3f1a69c

Please sign in to comment.