Github user jasongin commented on a diff in the pull request:

    https://github.com/apache/cordova-android/pull/240#discussion_r45385875
  
    --- Diff: bin/templates/cordova/lib/builders/GradleBuilder.js ---
    @@ -211,3 +212,54 @@ module.exports = GradleBuilder;
     function isAutoGenerated(file) {
         return fs.existsSync(file) && fs.readFileSync(file, 
'utf8').indexOf(MARKER) > 0;
     }
    +
    +/**
    + * A special superspawn-like implementation, required to workaround the 
issue
    + *   with java printing some necessary information to stderr instead of 
stdout.
    + *   This function redirects all stderr messages to current process 
stdout. See
    + *   https://issues.apache.org/jira/browse/CB-9971 for explanation.
    + *
    + * @param   {String}    cmd   A command to spawn
    + * @param   {String[]}  args  Command arguments. Note that on Windows 
arguments
    + *   will be concatenated into string and passed to 'cmd.exe' along with 
'/s'
    + *   and '/c' swithces for proper space-in-path handling
    + *
    + * @return  {Promise}        A promise, rejected with error message, if
    + *   underlying command exits with nonzero exit code, fulfilled otherwise
    + */
    +function spawnWithStderrRedirect(cmd, args) {
    +    var opts = { stdio: 'pipe' };
    +
    +    if (process.platform === 'win32') {
    +        // Work around spawn not being able to find .bat files.
    +        var joinedArgs = [cmd]
    +            .concat(args)
    +            .map(function(a){
    +                // Add quotes to arguments which contains whitespaces
    +                if (/^[^"].* .*[^"]/.test(a)) return '"' + a + '"';
    +                return a;
    +            }).join(' ');
    +
    +        args = ['/s', '/c'].concat('"' + joinedArgs + '"');
    +        cmd = 'cmd';
    +        opts.windowsVerbatimArguments = true;
    +    }
    +
    +    return Q.Promise(function (resolve, reject) {
    +        var proc = child_process.spawn(cmd, args, opts);
    +
    +        proc.stdout.on('data', process.stdout.write.bind(process.stdout));
    +        proc.stderr.on('data', function (data) {
    +            var isRedirectNeeded = data.toString().match(/^Picked up 
_JAVA_OPTIONS: /i);
    --- End diff --
    
    /regex/.test(str) is faster when all you need is a boolean result, not the 
detailed info that match() returns.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to