A wrapper which provides standard error/output line buffering for Node’s ChildProcess.
[BufferedProcess](../BufferedProcess/) = require('atom')
const command = 'ps'
const args = ['-ef']
const stdout = (output) => console.log(output)
const exit = (code) => console.log("ps -ef exited with #[code](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/code)")
const process = new BufferedProcess({command, args, stdout, exit})
Runs the given command by spawning a new child process.
Argument | Description |
---|---|
|
An Object with the following keys: |
|
The String command to execute. |
|
The Array of arguments to pass to the command (optional). |
|
Object (optional) The options Object to pass to Node’s |
|
Function (optional) The callback that receives a single argument which contains the standard output from the command. The callback is called as data is received but it’s buffered to ensure only complete lines are passed until the source stream closes. After the source stream has closed all remaining data is sent in a final call. |
|
|
|
Function (optional) The callback that receives a single argument which contains the standard error output from the command. The callback is called as data is received but it’s buffered to ensure only complete lines are passed until the source stream closes. After the source stream has closed all remaining data is sent in a final call. |
|
|
|
Function (optional) The callback which receives a single argument containing the exit status. |
|
|
|
Boolean (optional) Whether the command will automatically start when this BufferedProcess is created. Defaults to true. When set to false you must call the |
Will call your callback when an error will be raised by the process.
Usually this is due to the command not being available or not on the PATH.
You can call handle()
on the object passed to your callback to indicate
that you have handled this error.
Argument | Description |
---|---|
|
Function callback |
|
|
|
Object the error object |
|
Function call this to indicate you have handled the error. The error will not be thrown if this function is called. |
Return values |
---|
Returns a Disposable |
Terminate the process.