cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [42/50] [abbrv] cordova-common git commit: CB-8978: Add option to get resource-file from root
Date Tue, 06 Jun 2017 05:00:10 GMT
CB-8978: Add option to get resource-file from root

This will be needed for cleaning the resource-file targets, since they
are at the top level of the platform's config.xml.

 This closes #547


Project: http://git-wip-us.apache.org/repos/asf/cordova-common/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-common/commit/94430e68
Tree: http://git-wip-us.apache.org/repos/asf/cordova-common/tree/94430e68
Diff: http://git-wip-us.apache.org/repos/asf/cordova-common/diff/94430e68

Branch: refs/heads/master
Commit: 94430e683c75f9bc7a578a37a69a0057bc7b19f1
Parents: b788eae
Author: Darryl Pogue <darryl@dpogue.ca>
Authored: Thu Apr 20 23:45:12 2017 -0700
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Tue Apr 25 14:00:24 2017 -0700

----------------------------------------------------------------------
 spec/ConfigParser/ConfigParser.spec.js |  4 ++++
 spec/fixtures/test-config.xml          |  1 +
 src/ConfigParser/ConfigParser.js       | 17 ++++++++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-common/blob/94430e68/spec/ConfigParser/ConfigParser.spec.js
----------------------------------------------------------------------
diff --git a/spec/ConfigParser/ConfigParser.spec.js b/spec/ConfigParser/ConfigParser.spec.js
index cfb125b..034f3d7 100644
--- a/spec/ConfigParser/ConfigParser.spec.js
+++ b/spec/ConfigParser/ConfigParser.spec.js
@@ -313,6 +313,10 @@ describe('config.xml parser', function () {
                 expect(cfg.getFileResources('android').every(hasTargetPropertyDefined)).toBeTruthy();
                 expect(cfg.getFileResources('windows').every(hasArchPropertyDefined)).toBeTruthy();
             });
+
+            it('should find resources at the top level', function() {
+                expect(cfg.getFileResources('android', true).length).toBe(3);
+            });
         });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-common/blob/94430e68/spec/fixtures/test-config.xml
----------------------------------------------------------------------
diff --git a/spec/fixtures/test-config.xml b/spec/fixtures/test-config.xml
index 625d218..7969d64 100644
--- a/spec/fixtures/test-config.xml
+++ b/spec/fixtures/test-config.xml
@@ -106,6 +106,7 @@
         <icon src="res/windows/logo-small.scale-400_48.png" height="48" target="logo.png"/>
         <resource-file src="windowsconfig.json" target="windowsconfig.json" arch="x86"
device-target="all" />
     </platform>
+    <resource-file src="top-level-file.txt" target="toplevel.txt" />
     <plugin name="org.apache.cordova.pluginwithvars">
         <variable name="var" value="varvalue" />
     </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-common/blob/94430e68/src/ConfigParser/ConfigParser.js
----------------------------------------------------------------------
diff --git a/src/ConfigParser/ConfigParser.js b/src/ConfigParser/ConfigParser.js
index cd718de..0b02b4c 100644
--- a/src/ConfigParser/ConfigParser.js
+++ b/src/ConfigParser/ConfigParser.js
@@ -269,9 +269,11 @@ ConfigParser.prototype = {
     /**
      * Returns all resource-files for a specific platform.
      * @param  {string} platform Platform name
+     * @param  {boolean} includeGlobal Whether to return resource-files at the
+     *                                 root level.
      * @return {Resource[]}      Array of resource file objects.
      */
-    getFileResources: function(platform) {
+    getFileResources: function(platform, includeGlobal) {
         var fileResources = [];
 
         if (platform) { // platform specific resources
@@ -287,6 +289,19 @@ ConfigParser.prototype = {
             });
         }
 
+        if (includeGlobal) {
+            this.doc.findall('resource-file').forEach(function(tag) {
+                fileResources.push({
+                    platform: platform || null,
+                    src: tag.attrib.src,
+                    target: tag.attrib.target,
+                    versions: tag.attrib.versions,
+                    deviceTarget: tag.attrib['device-target'],
+                    arch: tag.attrib.arch
+                });
+            });
+        }
+
         return fileResources;
     },
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message