[
https://issues.apache.org/jira/browse/CB-8521?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14358284#comment-14358284
]
ASF GitHub Bot commented on CB-8521:
------------------------------------
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.
> 'cordova plugin save' should save all installed plugins and their
> version/git-url/folder-location into config.xml
> -----------------------------------------------------------------------------------------------------------------
>
> Key: CB-8521
> URL: https://issues.apache.org/jira/browse/CB-8521
> Project: Apache Cordova
> Issue Type: New Feature
> Reporter: Omar Mefire
> Assignee: Omar Mefire
>
> In addition to using 'cordova plugin add org.apache.cordova.device --save' to
> both add and save a plugin to config.xml, It would be useful to have a way to
> 'mass save' already installed plugins to config.xml.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]