cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martincgg <...@git.apache.org>
Subject [GitHub] cordova-cli pull request: CB-6329 improve 'cordova info' command
Date Thu, 03 Apr 2014 17:03:13 GMT
Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-cli/pull/151#discussion_r11261250
  
    --- Diff: src/info.js ---
    @@ -16,123 +16,99 @@
         specific language governing permissions and limitations
         under the License.
     */
    -var cordova_util  = require('./util'),
    -    shell         = require('shelljs'),
    -    path          = require('path'),
    -    fs            = require('fs'),
    -    Q             = require('q'),
    -    events        = require('./events');
    -
    -/*
    -    A utility funciton to help output the information needed
    -    when submitting a help request.
    -
    -    Outputs to a file
    -*/
    +    var cordova_util  = require('./util'),
    +        path          = require('path'),
    +        fs            = require('fs'),
    +        child_process = require('child_process'),
    +        Q             = require('q'),
    +        info_utils 	  = require('./info-utils');
    +
    +    /*
    +        A utility funciton to help output the information needed
    +        when submitting a help request.
    +
    +        Outputs to a file
    +    */
     module.exports = function info() {
    -
    -    //Get the template
    -    var projectRoot = cordova_util.cdProjectRoot();
    -
    -    var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split("\n"),
    +        //Get projectRoot 
    +        var projectRoot = cordova_util.cdProjectRoot(),
             output;
    -
    -    output = raw.map(function(line) {
    -        if(line.match('    %') ) {
    -            var type = (line.substr(5)).replace("\r",""),
    -                out = "";
    -
    -            switch(type) {
    -            case "Node":
    -                out = shell.exec('node --version',{silent:true}).output;
    -                break;
    -            case "Cordova":
    -                out = require('../package').version;
    -                break;
    -            case "Config":
    -                out = fs.readFileSync( cordova_util.projectConfig(projectRoot) );
    -                break;
    -            case "Platforms":
    -                out = doPlatforms( projectRoot );
    -                break;
    -            case "Plugins":
    -                out = doPlugins( projectRoot );
    -                break;
    -            default:
    -                break;
    -            }
    -            return line.replace( "%"+type, out );
    -        } else {
    -            return line;
    +        if (!projectRoot) {
    +            return Q.reject( new Error('Current working directory is not a Cordova-based
project.') );
             }
    -    }).join("\n");
     
    -    // /*
    -    //     Write to File;
    -    // */
    -    events.emit('results', output);
    -    fs.writeFileSync('info.txt', output );
    -    return Q();
    +        delLog(projectRoot);
    +        //Array of functions, Q.allSettled
    +        return Q.allSettled([ (function (){
    --- End diff --
    
    Q.allSettled, it just accept functions, so with using it in that way,  the function declarated
and at the same time, is executed.


---
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.
---

Mime
View raw message