cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vladimir-kotikov <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: CB-8521 `cordova plugin save` should sav...
Date Thu, 12 Mar 2015 08:23:39 GMT
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/178#discussion_r26284603
  
    --- Diff: cordova-lib/src/cordova/plugin.js ---
    @@ -295,14 +307,87 @@ module.exports = function plugin(command, targets, opts) {
                 }).then(function() {
                     return hooksRunner.fire('after_plugin_search');
                 });
    +        case 'save':
    +            // save the versions/folders/git-urls of currently installed plugins into
config.xml
    +            return save(projectRoot, opts);
             default:
                 return list(projectRoot, hooksRunner);
         }
     };
     
    +function save(projectRoot, opts){
    +    var xml = cordova_util.projectConfig(projectRoot);
    +    var cfg = new ConfigParser(xml);
    +
    +    // First, remove all pre-existing plugins from config.xml
    +    cfg.getPluginIdList().forEach(function(plugin){
    +        cfg.removePlugin(plugin);
    +    });
    +
    +    // It might be the case that fetch.json file is not yet existent.
    +    // for example: when we have never ran the command 'cordova plugin add foo' on the
project
    +    // in that case, there's nothing to do except bubble up the error
    +    function onFileNotFoundException(err){
    +        return Q.reject(err.message);
    +    }
    +
    +    // Then, save top-level plugins and their sources
    +    return Q().then(function(){
    --- End diff --
    
    Since that there is no async code in this function, IMHO it'll be better to avoid wrapping
it into a promise and just return fullfilled/rejected promise.


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