cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblotsky <...@git.apache.org>
Subject [GitHub] cordova-android pull request: CB-9971 Redirect gradlew stderr to c...
Date Wed, 11 Nov 2015 18:23:21 GMT
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-android/pull/240#discussion_r44566177
  
    --- Diff: bin/templates/cordova/lib/builders/GradleBuilder.js ---
    @@ -211,3 +209,46 @@ 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) {
    +    return Q.Promise(function (resolve, reject) {
    +        // Work around spawn not being able to find .bat files.
    +        var opts = { stdio: [0,1,1] };
    +        if (process.platform === 'win32') {
    +            var joinedArgs = [cmd]
    +                .concat(args)
    +                .map(function(a){
    +                    if (/^[^"].* .*[^"]/.test(a)) return '"' + a + '"';
    +                    return a;
    +                })
    +                .join(' ');
    +
    +            args = ['/s', '/c'].concat('"' + joinedArgs + '"')/*, '"' + [cmd].concat(args).map(function(a){if
(/^[^"].* .*[^"]/.test(a)) return '"' + a + '"'; return a;}).join(' ')+'"']*/;
    +            cmd = 'cmd';
    +            opts.windowsVerbatimArguments = true;
    +        }
    +        require('child_process')
    --- End diff --
    
    Please put the `require` at the top of the file.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message