CB-13145: added variable replacing to framework tag
authorSteve Gill <stevengill97@gmail.com>
Fri, 18 Aug 2017 00:18:12 +0000 (17:18 -0700)
committerSteve Gill <stevengill97@gmail.com>
Wed, 30 Aug 2017 05:41:16 +0000 (22:41 -0700)
src/PluginInfo/PluginInfo.js
src/PluginManager.js

index 75c96c1..5b088ca 100644 (file)
@@ -306,15 +306,33 @@ function PluginInfo (dirname) {
             return n.attrib.name;
         });
     };
-    self.getFrameworks = function (platform) {
+
+    self.getFrameworks = function (platform, options) {
         return _getTags(self._et, 'framework', platform, function (el) {
+            var src = el.attrib.src;
+            var vars = {};
+            if (options) {
+                vars = options.cli_variables;
+                if (Object.keys(vars).length === 0) {
+                    // get variable defaults from plugin.xml for removal
+                    vars = self.getPreferences(platform);
+                }
+
+                var regExp;
+                // Iterate over plugin variables.
+                // Replace them in framework src if they exist
+                Object.keys(vars).forEach(function (name) {
+                    regExp = new RegExp('\\$' + name, 'g');
+                    src = src.replace(regExp, vars[name]);
+                });
+            }
             var ret = {
                 itemType: 'framework',
                 type: el.attrib.type,
                 parent: el.attrib.parent,
                 custom: isStrTrue(el.attrib.custom),
                 embed: isStrTrue(el.attrib.embed),
-                src: el.attrib.src,
+                src: src,
                 spec: el.attrib.spec,
                 weak: isStrTrue(el.attrib.weak),
                 versions: el.attrib.versions,
@@ -328,14 +346,14 @@ function PluginInfo (dirname) {
     };
 
     self.getFilesAndFrameworks = getFilesAndFrameworks;
-    function getFilesAndFrameworks (platform) {
+    function getFilesAndFrameworks (platform, options) {
         // Please avoid changing the order of the calls below, files will be
         // installed in this order.
         var items = [].concat(
             self.getSourceFiles(platform),
             self.getHeaderFiles(platform),
             self.getResourceFiles(platform),
-            self.getFrameworks(platform),
+            self.getFrameworks(platform, options),
             self.getLibFiles(platform)
         );
         return items;
index 7b8a0d4..b875d0e 100644 (file)
@@ -92,7 +92,7 @@ PluginManager.prototype.doOperation = function (operation, plugin, options) {
     var actions = new ActionStack();\r
 \r
     // gather all files need to be handled during operation ...\r
-    plugin.getFilesAndFrameworks(this.platform)\r
+    plugin.getFilesAndFrameworks(this.platform, options)\r
         .concat(plugin.getAssets(this.platform))\r
         .concat(plugin.getJsModules(this.platform))\r
         // ... put them into stack ...\r