cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [05/16] git commit: config-changes.js: Some simple changes & moving funcs around for better readability.
Date Wed, 19 Feb 2014 20:32:51 GMT
config-changes.js: Some simple changes & moving funcs around for better readability.

Replaced several instances of require('./../platforms') with a single one. The
reverse of this was done some time ago for a mysterious and undocumented reason
here:

github.com/apache/cordova-plugman/commit/f025a2a98a4bec04d825d0ac1bd55e4fce61b37a


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/2dc5c150
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/2dc5c150
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/2dc5c150

Branch: refs/heads/master
Commit: 2dc5c150b4ac48b758e1a79a32454583869f52cd
Parents: c506986
Author: Mark Koudritsky <kamrik@chromium.org>
Authored: Mon Feb 3 21:26:57 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Wed Feb 19 15:32:19 2014 -0500

----------------------------------------------------------------------
 src/util/config-changes.js | 63 +++++++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2dc5c150/src/util/config-changes.js
----------------------------------------------------------------------
diff --git a/src/util/config-changes.js b/src/util/config-changes.js
index 73ed735..7d05a25 100644
--- a/src/util/config-changes.js
+++ b/src/util/config-changes.js
@@ -40,11 +40,9 @@ var fs   = require('fs'),
     et   = require('elementtree'),
     xml_helpers = require('./../util/xml-helpers'),
     ios_parser = require('./../platforms/ios'),
+    platforms = require('./../platforms'),
     plist_helpers = require('./../util/plist-helpers');
 
-function checkPlatform(platform) {
-    if (!(platform in require('./../platforms'))) throw new Error('platform "' + platform
+ '" not recognized.');
-}
 
 // These frameworks are required by cordova-ios by default. We should never add/remove them.
 var keep_these_frameworks = [
@@ -54,8 +52,39 @@ var keep_these_frameworks = [
     'AssetsLibrary.framework'
 ];
 
+
 var package = module.exports = {};
 
+package.process = process_all;
+function process_all(plugins_dir, project_dir, platform) {
+    checkPlatform(platform);
+
+    var platform_config = module.exports.get_platform_json(plugins_dir, platform);
+    // Uninstallation first
+    platform_config.prepare_queue.uninstalled.forEach(function(u) {
+        module.exports.remove_plugin_changes(platform, project_dir, plugins_dir, u.plugin,
u.id, u.topLevel, true);
+    });
+
+    // Now handle installation
+    var cache = {};
+    platform_config.prepare_queue.installed.forEach(function(u) {
+        module.exports.add_plugin_changes(platform, project_dir, plugins_dir, u.plugin, u.vars,
u.topLevel, true, cache);
+    });
+
+    platform_config = module.exports.get_platform_json(plugins_dir, platform);
+
+    // Empty out uninstalled queue.
+    platform_config.prepare_queue.uninstalled = [];
+    // Empty out installed queue.
+    platform_config.prepare_queue.installed = [];
+    // save
+    module.exports.save_platform_json(platform_config, plugins_dir, platform);
+}
+
+function checkPlatform(platform) {
+    if (!(platform in platforms)) throw new Error('platform "' + platform + '" not recognized.');
+}
+
 package.add_installed_plugin_to_prepare_queue = add_installed_plugin_to_prepare_queue;
 function add_installed_plugin_to_prepare_queue(plugins_dir, plugin, platform, vars, is_top_level)
{
     checkPlatform(platform);
@@ -106,7 +135,7 @@ function generate_plugin_config_munge(plugin_dir, platform, project_dir,
vars) {
     checkPlatform(platform);
 
     vars = vars || {};
-    var platform_handler = require('./../platforms')[platform];
+    var platform_handler = platforms[platform];
     // Add PACKAGE_NAME variable into vars
     if (!vars['PACKAGE_NAME']) {
         vars['PACKAGE_NAME'] = platform_handler.package_name(project_dir);
@@ -444,32 +473,6 @@ function add_plugin_changes(platform, project_dir, plugins_dir, plugin_id,
plugi
     }
 }
 
-package.process = process_all;
-function process_all(plugins_dir, project_dir, platform) {
-    checkPlatform(platform);
-
-    var platform_config = module.exports.get_platform_json(plugins_dir, platform);
-    // Uninstallation first
-    platform_config.prepare_queue.uninstalled.forEach(function(u) {
-        module.exports.remove_plugin_changes(platform, project_dir, plugins_dir, u.plugin,
u.id, u.topLevel, true);
-    });
-
-    // Now handle installation
-    var cache = {};
-    platform_config.prepare_queue.installed.forEach(function(u) {
-        module.exports.add_plugin_changes(platform, project_dir, plugins_dir, u.plugin, u.vars,
u.topLevel, true, cache);
-    });
-
-    platform_config = module.exports.get_platform_json(plugins_dir, platform);
-
-    // Empty out uninstalled queue.
-    platform_config.prepare_queue.uninstalled = [];
-    // Empty out installed queue.
-    platform_config.prepare_queue.installed = [];
-    // save
-    module.exports.save_platform_json(platform_config, plugins_dir, platform);
-}
-
 // determine if a plist file is binary
 function isBinaryPlist(filename) {
     // I wish there was a synchronous way to read only the first 6 bytes of a


Mime
View raw message