You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/02/01 14:16:39 UTC
[jira] [Commented] (CB-10052) Improve superspawn to allow to handle
spawned process io streams
[ https://issues.apache.org/jira/browse/CB-10052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15126228#comment-15126228 ]
ASF GitHub Bot commented on CB-10052:
-------------------------------------
GitHub user vladimir-kotikov opened a pull request:
https://github.com/apache/cordova-lib/pull/369
CB-10052 Expose child process' io streams via promise progress notification
This implements [CB-10052](https://issues.apache.org/jira/browse/CB-10052).
The `superspawn.spawn` promise now emits notifications, which caller can subscribe to using `progress` method:
```
superspawn.spawn('adb', ['devices'])
.progress(function(data){
if (data.stderr) console.error('"adb devices" raised an error: ' + data.stderr);
})
.then(function(devices){
// Do something...
})
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/MSOpenTech/cordova-lib CB-10052
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cordova-lib/pull/369.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #369
----
commit 5a37978e9aeeeda4f71e876299fce4358f4ed2fd
Author: Vladimir Kotikov <v-...@microsoft.com>
Date: 2016-01-22T13:39:13Z
CB-10052 Expose child process' io streams via promise progress notification
----
> Improve superspawn to allow to handle spawned process io streams
> ----------------------------------------------------------------
>
> Key: CB-10052
> URL: https://issues.apache.org/jira/browse/CB-10052
> Project: Apache Cordova
> Issue Type: Improvement
> Components: CordovaCommon
> Affects Versions: 1.0.0
> Reporter: Vladimir Kotikov
> Assignee: Vladimir Kotikov
> Fix For: 1.1.0
>
>
> Sometimes it is useful to process spawned process stdout and stderr in some way before out this to console. The current implementation of superspawn doesn't give a way to do this. One of the cases when this could be helpful - CB-9971 (see https://github.com/apache/cordova-android/pull/240 for some discussion).
> The proposed approach is:
> 1. Add ability to accept any valid stdio configuration, just like the original child_process.spawn does (https://nodejs.org/api/child_process.html#child_process_options_stdio)
> 2. Give a way to caller to listen to stdout and stderr events. This might be implemented as resultant promise progress notification:
> {code:JavaScript}
> spawn('mycommand', [], {stdio: 'pipe'})
> .progress(function (stdio){
> if (stdio.stderr) {
> console.error(stdio.stderr);
> }
> })
> .then(function(result){
> // do other stuff
> })
> {code}
> Another option is to return na object that implements both EventEmitter and Promise interfaces, so anybody might subscribe to its events.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org