The Gallery is deprecated. No new Gallery components may be submitted, and modifying existing components is disabled. For more information please read the Gallery Deprecation blog post. This is a static snapshot of the Gallery for archive purposes.
See 42 more by this user. Created: 10/13/11
Project: YUI 3
License: YUI BSD
YUI Version: 3.4.1
Free for use.
This is a convenience wrapper around child processes in Node.js. This is not intended to run in a web browser or environment outside of Node.js.
This module was made for Node.js 0.4.x. It may not work well or at all with current versions of Node.
To install, click the download link below. Extract the files.
This module has to be defined for loader before it can be used. See the code sample.
Y.ChildProcess is an instanceable object. Its constructor function accepts an attributes object with the following members.
args: Array of command line arguments. Refer to Node.js child_process.spawn documentation.
command: The command to execute. Refer to Node.js child_process.spawn documentation.
options: Additional options. Refer to Node.js child_process.spawn documentation.
stderrEncoding: Encoding may be one of 'ascii', 'base64', or 'utf8'. If left undefined, the stderr event will emit a Buffer instead of a string.
stdOutEncoding: Encoding may be one of 'ascii', 'base64', or 'utf8'. If left undefined, the stderr event will emit a Buffer instead of a string.
Each Y.ChildProcess instance has two read only attributes.
pid: The PID of the child process.
ready: This will be true when the stdin of the child process is writable and its kernel buffer is not full.
Each Y.ChildProcess instance has five public events.
drain: Fires when the stdin of the child process is writable again after having reported its kernel buffer was full.
error: Fires when there is an error in any stream of the child process.
exit: Fires when the child process exits.
stderr: Fired when stderr receives data.
stdout: Fired when stdout receives data.
Each Y.ChildProcess instance has two public methods.
kill: Sends a signal to the child process. Refer to Node.js child.kill documentation. Note that while the method is called kill, the signal delivered to the child process may not actually kill it. kill really just sends a signal to a process.
write: Writes data to the stdin of the child process. If the stdin of the child process has reported its kernel buffer is full, the write will be queued until the drain event.
require('yui3').YUI({
modules: {
'gallery-child-process': {
fullpath: '/path/to/install/gallery-child-process-min.js',
requires: [
'base'
]
}
}
}).use('gallery-child-process', function(Y) {
var ls = new Y.ChildProcess({
args: [
'-lh',
'/usr'
],
command: 'ls',
stdoutEncoding: 'utf8'
});
ls.on('stdout', function (eventFacade) {
Y.log(eventFacade.data, 'stdout');
});
ls.on('exit', function (eventFacade) {
Y.log('child process exited with code: ' + eventFacade.code);
});
});
All code on this site is licensed under the BSD License unless stated otherwise.