Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README to current examples (remove pipes, onFinished->done, stdin... #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ and in our case, from addon-sdk libraries :)
arguments: ['$@', '$ENV_TEST'],
environment: ['ENV_TEST=OK'],

stdin: subprocess.WritablePipe(function() {
this.write("stdin");
this.close();
}),
stdout: subprocess.ReadablePipe(function(data) {
stdin: function(stdin) {
stdin.write("stdin");
stdin.close();
},
stdout: function(data) {
// data should be equal to: "stdin OK"

}),
stderr: subprocess.ReadablePipe(function(data) {
},
stderr: function(data) {

}),
onFinished: subprocess.Terminate(function() {

}),
},
done: function(result) {
console.log("process terminated with " + result.exitCode + "\n");
},
mergeStderr: false
});

Expand Down
22 changes: 13 additions & 9 deletions lib/subprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ function getPlatformValue(valueType) {

var gDebugFunc = null,
gLogFunc = null,
gXulRuntime = null;
gXulRuntime = null,
wrap = function (obj) {return obj;};

function LogError(s) {
if (gLogFunc)
Expand Down Expand Up @@ -464,6 +465,9 @@ var subprocess = {
},
registerLogHandler: function(func) {
gLogFunc = func;
},
addWrapper: function (userWrapper) {
wrap = userWrapper;
}
};

Expand Down Expand Up @@ -1022,11 +1026,11 @@ function subprocess_win32(options) {
setTimeout(function _done() {
if (options.done) {
try {
options.done({
options.done(wrap({
exitCode: exitCode,
stdout: output,
stderr: error,
});
}));
}
catch (ex) {
// prevent from blocking if options.done() throws an error
Expand All @@ -1053,14 +1057,14 @@ function subprocess_win32(options) {

if(typeof(options.stdin) == 'function') {
try {
options.stdin({
options.stdin(wrap({
write: function(data) {
writeStdin(data);
},
close: function() {
closeStdinHandle();
}
});
}));
}
catch (ex) {
// prevent from failing if options.stdin() throws an exception
Expand Down Expand Up @@ -1611,11 +1615,11 @@ function subprocess_unix(options) {
setTimeout(function _done() {
if (options.done) {
try {
options.done({
options.done(wrap({
exitCode: exitCode,
stdout: output,
stderr: error,
});
}));
}
catch(ex) {
// prevent from blocking if options.done() throws an error
Expand Down Expand Up @@ -1647,14 +1651,14 @@ function subprocess_unix(options) {
createStdinWriter();
if(typeof(options.stdin) == 'function') {
try {
options.stdin({
options.stdin(wrap({
write: function(data) {
writeStdin(data);
},
close: function() {
closeStdinHandle();
}
});
}));
}
catch(ex) {
// prevent from failing if options.stdin() throws an exception
Expand Down