Repository: cordova-lib
Updated Branches:
  refs/heads/master d1347c2ac -> 52d2a75cf


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-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/52d2a75c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/52d2a75c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/52d2a75c

Branch: refs/heads/master
Commit: 52d2a75cf11096909d71554cce47092043835711
Parents: d1347c2
Author: Darryl Pogue <[email protected]>
Authored: Thu Apr 20 23:45:12 2017 -0700
Committer: Steve Gill <[email protected]>
Committed: Tue Apr 25 14:00:24 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/52d2a75c/cordova-common/spec/ConfigParser/ConfigParser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/ConfigParser/ConfigParser.spec.js 
b/cordova-common/spec/ConfigParser/ConfigParser.spec.js
index cfb125b..034f3d7 100644
--- a/cordova-common/spec/ConfigParser/ConfigParser.spec.js
+++ b/cordova-common/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-lib/blob/52d2a75c/cordova-common/spec/fixtures/test-config.xml
----------------------------------------------------------------------
diff --git a/cordova-common/spec/fixtures/test-config.xml 
b/cordova-common/spec/fixtures/test-config.xml
index 625d218..7969d64 100644
--- a/cordova-common/spec/fixtures/test-config.xml
+++ b/cordova-common/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-lib/blob/52d2a75c/cordova-common/src/ConfigParser/ConfigParser.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/ConfigParser/ConfigParser.js 
b/cordova-common/src/ConfigParser/ConfigParser.js
index cd718de..0b02b4c 100644
--- a/cordova-common/src/ConfigParser/ConfigParser.js
+++ b/cordova-common/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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to