diff options
author | isaacs <i@izs.me> | 2011-10-12 20:45:38 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-10-12 20:45:38 +0400 |
commit | f70e3d4baca86678c2dd9f94bfb7f87328de349d (patch) | |
tree | c05fee09ac646745b38df4ab29b69ed9c4280b3f /lib | |
parent | 0ae422cbd64cad87f26093a9ff99078f3672eff3 (diff) |
s/stdio/tty/g
Diffstat (limited to 'lib')
-rw-r--r-- | lib/completion.js | 3 | ||||
-rw-r--r-- | lib/search.js | 8 | ||||
-rw-r--r-- | lib/utils/config-defs.js | 5 | ||||
-rw-r--r-- | lib/utils/exec.js | 7 | ||||
-rw-r--r-- | lib/utils/output.js | 19 | ||||
-rw-r--r-- | lib/utils/prompt.js | 6 | ||||
-rw-r--r-- | lib/xmas.js | 2 |
7 files changed, 19 insertions, 31 deletions
diff --git a/lib/completion.js b/lib/completion.js index 40b7b430e..5ff765a08 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -15,7 +15,6 @@ var output = require("./utils/output.js") }) , shorthandNames = Object.keys(shorthands) , allConfs = configNames.concat(shorthandNames) - , stdio = process.binding("stdio") , npm = require("../npm.js") completion.completion = function (opts, cb) { @@ -201,7 +200,7 @@ function wrapCb (cb, opts) { return function (er, compls) { }) console.error([er && er.stack, compls, opts.partialWord]) if (er || compls.length === 0) return cb(er) - output.write(compls.join("\n"), stdio.stdoutFD, false, cb) + output.write(compls.join("\n"), 1, false, cb) }} // the current word has a dash. Return the config names, diff --git a/lib/search.js b/lib/search.js index f16a1c98c..63ca66763 100644 --- a/lib/search.js +++ b/lib/search.js @@ -120,12 +120,10 @@ function filterWords (data, args, notArgs) { function prettify (data, args) { try { - var stdio = process.binding("stdio") - , cols = stdio.isatty(stdio.stdoutFD) ? - ( stdio.getColumns ? stdio.getColumns() - : stdio.getWindowSize ? stdio.getWindowSize()[1] + var tty = require("tty") + , cols = tty.isatty(tty.stdoutFD) ? + ( tty.getWindowSize ? tty.getWindowSize()[1] : Infinity ) - : Infinity } catch (ex) { cols = Infinity } // name, desc, author, keywords diff --git a/lib/utils/config-defs.js b/lib/utils/config-defs.js index b88a7cfe2..2ba33b17e 100644 --- a/lib/utils/config-defs.js +++ b/lib/utils/config-defs.js @@ -2,7 +2,6 @@ var path = require("path") - , stdio = process.binding("stdio") , url = require("url") , Stream = require("stream").Stream , semver = require("semver") @@ -126,7 +125,7 @@ Object.defineProperty(exports, "defaults", {get: function () { , "init.author.email" : "" , "init.author.url" : "" , link: false - , logfd : stdio.stderrFD + , logfd : 2 , loglevel : "warn" , logprefix : process.platform !== "win32" , long : false @@ -134,7 +133,7 @@ Object.defineProperty(exports, "defaults", {get: function () { , npaturl : "http://npat.npmjs.org/" , npat : false , "onload-script" : false - , outfd : stdio.stdoutFD + , outfd : 1 , parseable : false , pre: false , prefix : (process.env.DESTDIR || "") diff --git a/lib/utils/exec.js b/lib/utils/exec.js index 47a2451e5..049f7975b 100644 --- a/lib/utils/exec.js +++ b/lib/utils/exec.js @@ -56,7 +56,7 @@ function exec (cmd, args, env, takeOver, cwd, uid, gid, cb) { return cp } -function logger (d) { if (d) process.binding("stdio").writeError(d+"") } +function logger (d) { if (d) process.stderr.write(d+"") } function pipe (cp1, cp2, cb) { util.pump(cp1.stdout, cp2.stdin) var errState = null @@ -89,10 +89,7 @@ function pipe (cp1, cp2, cb) { } function spawn (c, a, env, takeOver, cwd, uid, gid) { - var stdio = process.binding("stdio") - , fds = [ stdio.stdinFD || 0 - , stdio.stdoutFD || 1 - , stdio.stderrFD || 2 ] + var fds = [ 0, 1, 2 ] , opts = { customFds : takeOver ? fds : [-1,-1,-1] , env : env || process.env , cwd : cwd || null } diff --git a/lib/utils/output.js b/lib/utils/output.js index 80c4c2e74..101018a91 100644 --- a/lib/utils/output.js +++ b/lib/utils/output.js @@ -5,7 +5,7 @@ exports.doColor = doColor exports.write = write var npm = require("../../npm.js") - , stdio = process.binding("stdio") + , tty = require("tty") , streams = {} , ttys = {} , net = require("net") @@ -20,11 +20,11 @@ function doColor (stream) { } function isatty (stream) { // console.error("isatty?", stream) - if (!stdio.isatty) return true + if (!tty.isatty) return true if (!stream) return false if (stream.isTTY) return true if (stream && (typeof stream.fd === "number")) { - stream.isTTY = stdio.isatty(stream.fd) + stream.isTTY = tty.isatty(stream.fd) } return stream.isTTY } @@ -92,8 +92,8 @@ function write (args, stream, lf, cb) { // use the \r\n in case we're in raw mode. msg = msg.split(/\r?\n/).concat("").join(lf ? "\r\n" : "\n") // output to stderr should be synchronous - if (stream === process.stderr || stream.fd === stdio.stderrFD) { - stdio.writeError(msg) + if (stream === process.stderr || stream.fd === 2) { + process.stderr.write(msg) if (cb) cb() return true } @@ -123,21 +123,16 @@ function getStream (fd) { } else if (streams[fd]) { stream = streams[fd] } else { - // console.error("setting based on stdio") - var stdio = process.binding("stdio") - // console.error(stdio) switch (fd) { - case stdio.stdoutFD: + case 1: stream = process.stdout stream.fd = fd stream.writable = true - // console.error("---stdoutFD", stream) break - case stdio.stderrFD: + case 2: stream = process.stderr stream.fd = fd stream.writable = true - // console.error("---stderrFD", stream) break default: try { diff --git a/lib/utils/prompt.js b/lib/utils/prompt.js index abf6b8a7e..d23e4ac58 100644 --- a/lib/utils/prompt.js +++ b/lib/utils/prompt.js @@ -3,7 +3,7 @@ module.exports = prompt var log = require("./log.js") , buffer = "" - , stdio = process.binding("stdio") + , tty = require("tty") function prompt (p, def, silent, cb) { if (!cb) cb = silent, silent = false @@ -43,14 +43,14 @@ function read (def, cb) { function silentRead (def, cb) { var stdin = process.openStdin() , val = "" - stdio.setRawMode(true) + tty.setRawMode(true) stdin.resume() stdin.on("error", cb) stdin.on("data", function D (c) { c = "" + c switch (c) { case "\n": case "\r": case "\r\n": case "\u0004": - stdio.setRawMode(false) + tty.setRawMode(false) stdin.removeListener("data", D) stdin.removeListener("error", cb) val = val.trim() || def diff --git a/lib/xmas.js b/lib/xmas.js index 429b34aae..c039e6de0 100644 --- a/lib/xmas.js +++ b/lib/xmas.js @@ -13,7 +13,7 @@ var s = " \u2605" , oc = [21,33,34,35,36,37] , l = "\u005e" -function w (s) { process.binding("stdio").writeError(s) } +function w (s) { process.stderr.write(s) } w("\n") ;(function T (H) { |