Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-10052

Improve superspawn to allow to handle spawned process io streams

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0
    • 1.1.0
    • cordova-common
    • None

    Description

      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:

      spawn('mycommand', [], {stdio: 'pipe'})
      .progress(function (stdio){
          if (stdio.stderr) {
              console.error(stdio.stderr);
          }
      })
      .then(function(result){
          // do other stuff
      })
      

      Another option is to return na object that implements both EventEmitter and Promise interfaces, so anybody might subscribe to its events.

      Attachments

        Issue Links

          Activity

            People

              vladimir.kotikov Vladimir Kotikov
              vladimir.kotikov Vladimir Kotikov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: