[Pkg-javascript-commits] [node-debug] 01/08: Imported Upstream version 2.1.0
Leo Iannacone
l3on-guest at moszumanska.debian.org
Thu Oct 16 07:52:32 UTC 2014
This is an automated email from the git hooks/post-receive script.
l3on-guest pushed a commit to branch master
in repository node-debug.
commit 3b7cacc68559367d29f40d3bd3d573530f31ad0d
Author: Leo Iannacone <l3on at ubuntu.com>
Date: Thu Oct 16 09:38:10 2014 +0200
Imported Upstream version 2.1.0
---
History.md | 7 +++++
component.json | 2 +-
node.js | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
package.json | 5 ++--
4 files changed, 93 insertions(+), 5 deletions(-)
diff --git a/History.md b/History.md
index 79429ff..bcbc3bd 100644
--- a/History.md
+++ b/History.md
@@ -1,4 +1,11 @@
+2.1.0 / 2014-10-15
+==================
+
+ * node: implement `DEBUG_FD` env variable support
+ * package: update "browserify" to v6.1.0
+ * package: add "license" field to package.json (#135, @panuhorsmalahti)
+
2.0.0 / 2014-09-01
==================
diff --git a/component.json b/component.json
index db1ceed..7ee3d13 100644
--- a/component.json
+++ b/component.json
@@ -2,7 +2,7 @@
"name": "debug",
"repo": "visionmedia/debug",
"description": "small debugging utility",
- "version": "2.0.0",
+ "version": "2.1.0",
"keywords": [
"debug",
"log",
diff --git a/node.js b/node.js
index db86f64..5dc999f 100644
--- a/node.js
+++ b/node.js
@@ -26,13 +26,25 @@ exports.useColors = useColors;
exports.colors = [6, 2, 3, 4, 5, 1];
/**
+ * The file descriptor to write the `debug()` calls to.
+ * Set the `DEBUG_FD` env variable to override with another value. i.e.:
+ *
+ * $ DEBUG_FD=3 node script.js 3>debug.log
+ */
+
+var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
+var stream = 1 === fd ? process.stdout :
+ 2 === fd ? process.stderr :
+ createWritableStdioStream(fd);
+
+/**
* Is stdout a TTY? Colored output is enabled when `true`.
*/
function useColors() {
var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase();
if (0 === debugColors.length) {
- return tty.isatty(1);
+ return tty.isatty(fd);
} else {
return '0' !== debugColors
&& 'no' !== debugColors
@@ -91,7 +103,7 @@ function formatArgs() {
*/
function log() {
- return console.error.apply(console, arguments);
+ return stream.write(util.format.apply(this, arguments) + '\n');
}
/**
@@ -123,6 +135,74 @@ function load() {
}
/**
+ * Copied from `node/src/node.js`.
+ *
+ * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
+ * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
+ */
+
+function createWritableStdioStream (fd) {
+ var stream;
+ var tty_wrap = process.binding('tty_wrap');
+
+ // Note stream._type is used for test-module-load-list.js
+
+ switch (tty_wrap.guessHandleType(fd)) {
+ case 'TTY':
+ stream = new tty.WriteStream(fd);
+ stream._type = 'tty';
+
+ // Hack to have stream not keep the event loop alive.
+ // See https://github.com/joyent/node/issues/1726
+ if (stream._handle && stream._handle.unref) {
+ stream._handle.unref();
+ }
+ break;
+
+ case 'FILE':
+ var fs = require('fs');
+ stream = new fs.SyncWriteStream(fd, { autoClose: false });
+ stream._type = 'fs';
+ break;
+
+ case 'PIPE':
+ case 'TCP':
+ var net = require('net');
+ stream = new net.Socket({
+ fd: fd,
+ readable: false,
+ writable: true
+ });
+
+ // FIXME Should probably have an option in net.Socket to create a
+ // stream from an existing fd which is writable only. But for now
+ // we'll just add this hack and set the `readable` member to false.
+ // Test: ./node test/fixtures/echo.js < /etc/passwd
+ stream.readable = false;
+ stream.read = null;
+ stream._type = 'pipe';
+
+ // FIXME Hack to have stream not keep the event loop alive.
+ // See https://github.com/joyent/node/issues/1726
+ if (stream._handle && stream._handle.unref) {
+ stream._handle.unref();
+ }
+ break;
+
+ default:
+ // Probably an error on in uv_guess_handle()
+ throw new Error('Implement me. Unknown stream file type!');
+ }
+
+ // For supporting legacy API we put the FD here.
+ stream.fd = fd;
+
+ stream._isStdio = true;
+
+ return stream;
+}
+
+/**
* Enable namespaces listed in `process.env.DEBUG` initially.
*/
diff --git a/package.json b/package.json
index 05b55d2..59c2aec 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "debug",
- "version": "2.0.0",
+ "version": "2.1.0",
"repository": {
"type": "git",
"url": "git://github.com/visionmedia/debug.git"
@@ -15,11 +15,12 @@
"contributors": [
"Nathan Rajlich <nathan at tootallnate.net> (http://n8.io)"
],
+ "license": "MIT",
"dependencies": {
"ms": "0.6.2"
},
"devDependencies": {
- "browserify": "5.11.0",
+ "browserify": "6.1.0",
"mocha": "*"
},
"main": "./node.js",
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-debug.git
More information about the Pkg-javascript-commits
mailing list