Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

net2 compatibility

  • Loading branch information...
commit d720cdff2a3beaaf938aab5323a0cc0978a374aa 1 parent 302d038
@felixge authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 lib/ugly.js
View
15 lib/ugly.js
@@ -1,5 +1,5 @@
var
- sys = require('sys'),
+ childProcess = require('child_process'),
path = require('path');
exports.createClient = function(options) {
@@ -9,7 +9,7 @@ exports.createClient = function(options) {
client = {
onClose: function() {},
},
- worker = process.createChildProcess(options.worker),
+ worker = childProcess.spawn(options.worker),
callbacks = [],
buffer = '',
parse = function(chunk) {
@@ -50,10 +50,13 @@ exports.createClient = function(options) {
buffer = buffer.substr(offset+1);
}
};
-
+
+ worker.stdout.setEncoding('utf8');
+ worker.stdout.addListener('data', parse);
+ worker.stderr.setEncoding('utf8');
+ worker.stderr.addListener('data', parse);
+
worker
- .addListener('output', parse)
- .addListener('error', parse)
.addListener('exit', function(code) {
client.onClose(code);
});
@@ -72,7 +75,7 @@ exports.createClient = function(options) {
message = JSON.stringify(args)+"\n";
// puts('> '+message);
- worker.write(message, 'utf8');
+ worker.stdin.write(message, 'utf8');
};
client.close = function() {
Please sign in to comment.
Something went wrong with that request. Please try again.