Constructor
new ProcessWrapper(command, args, options)
Parameters:
Name | Type | Description |
---|---|---|
command |
String | |
args |
Array.<string> | |
options |
SpawnOptions | Object | The same options that child_process.spawn(..) supports. |
- Source:
Members
isRunning :Boolean
Type:
- Boolean
- Source:
observable :Observable.<ProcessOutput>
Creates and returns a general Observable for any output of this Process. The
Observable will just observe any emits. Thus it never errors and never drains.
Type:
- Observable.<ProcessOutput>
- Source:
process :NodeJS.Process
Returns the underlying process as returned by child_process.
Type:
- NodeJS.Process
- Source:
result :ProcessResult|ProcessErrorResult|ProcessExit
This property will yield a value once the Process terminated. Note that in the
API of Observable, the complete()-function does not support arguments, so that
we cannot pass in the result there.
Instead the wrapper guarantees that, once the Process terminated, its result
will be made available before any events are omitted or complete() gets called.
Type:
- Source:
wasStarted :Boolean
Type:
- Boolean
- Source:
Methods
(async) run(emitOnly)
The default action to run this process. At the moment it defaults to spawn().
The default behavior may change in the future, so do not rely on this method
and use the specialized instantiation methods, if you require e.g. fork()
instead of spawn().
However regardless, this method guarantees that the process will be executed
and that its result can be observed or obtained by awaiting its termination
(that depends on the behavior of 'emitOnly').
Parameters:
Name | Type | Default | Description |
---|---|---|---|
emitOnly |
Boolean | true | If set to true, the resulting value of the resolving Promise will be empty (i.e. stdout and stderr will be empty and not be collected while the process is running; instead, all output is emitted (events and obser- vable) while the process is running). It is recommended to set this to true, if the underlying process outputs a lot of data to the std-streams. That data would otherwise be held in the node.js process. However, if set to false, the resulting value of the Promise will be the process' entire output. |
- Source:
runObservable() → {Observable.<ProcessOutput>}
The default action to start and observe this process. At the moment it defaults
to spawn() and thus spawnObservable(). The default behavior may change in the future,
so do not rely on this method and use the specialized instantiation methods, if you
require e.g. fork() instead of spawn().
However regardless, this method guarantees that the process will be executed and that
its result can be observed. When the process errors or terminates, the observable will
forward those errors or call onComplete() accordingly.
- Source:
Returns:
- Type
- Observable.<ProcessOutput>
spawnAsync(emitOnly) → {Promise.<ProcessResult>}
Launches the process using spawn().
Parameters:
Name | Type | Default | Description |
---|---|---|---|
emitOnly |
Boolean | true | Has the same effect as 'run(emitOnly)', please refer to the documentation there. |
- Source:
Returns:
The Promise will be rejected if the process
exits with a non-zero result or if, when spawning it, an error occurs. In the
first case, the result will be of type ProcessExit, while in the latter case, it
will be of type ProcessErrorResult. Both types inherit from ProcessResult.
- Type
- Promise.<ProcessResult>
spawnObservable() → {Observable.<ProcessOutput>}
Calls 'spawnAsync(emitOnly=true)' so that the entire Process becomes
observable while it runs. When the process errors or finishes, the
observable will output an error or complete, respectively.
- Source:
Returns:
- Type
- Observable.<ProcessOutput>