mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
updated bundled node_modules
This commit is contained in:
+148
-111
@@ -17,24 +17,21 @@
|
||||
under the License.
|
||||
*/
|
||||
|
||||
/* jshint sub:true */
|
||||
|
||||
var et = require('elementtree'),
|
||||
xml= require('../util/xml-helpers'),
|
||||
CordovaError = require('../CordovaError/CordovaError'),
|
||||
fs = require('fs'),
|
||||
events = require('../events');
|
||||
|
||||
var et = require('elementtree');
|
||||
var xml = require('../util/xml-helpers');
|
||||
var CordovaError = require('../CordovaError/CordovaError');
|
||||
var fs = require('fs');
|
||||
var events = require('../events');
|
||||
|
||||
/** Wraps a config.xml file */
|
||||
function ConfigParser(path) {
|
||||
function ConfigParser (path) {
|
||||
this.path = path;
|
||||
try {
|
||||
this.doc = xml.parseElementtreeSync(path);
|
||||
this.cdvNamespacePrefix = getCordovaNamespacePrefix(this.doc);
|
||||
et.register_namespace(this.cdvNamespacePrefix, 'http://cordova.apache.org/ns/1.0');
|
||||
} catch (e) {
|
||||
console.error('Parsing '+path+' failed');
|
||||
console.error('Parsing ' + path + ' failed');
|
||||
throw e;
|
||||
}
|
||||
var r = this.doc.getroot();
|
||||
@@ -43,11 +40,11 @@ function ConfigParser(path) {
|
||||
}
|
||||
}
|
||||
|
||||
function getNodeTextSafe(el) {
|
||||
function getNodeTextSafe (el) {
|
||||
return el && el.text && el.text.trim();
|
||||
}
|
||||
|
||||
function findOrCreate(doc, name) {
|
||||
function findOrCreate (doc, name) {
|
||||
var ret = doc.find(name);
|
||||
if (!ret) {
|
||||
ret = new et.Element(name);
|
||||
@@ -56,12 +53,12 @@ function findOrCreate(doc, name) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
function getCordovaNamespacePrefix(doc){
|
||||
function getCordovaNamespacePrefix (doc) {
|
||||
var rootAtribs = Object.getOwnPropertyNames(doc.getroot().attrib);
|
||||
var prefix = 'cdv';
|
||||
for (var j = 0; j < rootAtribs.length; j++ ) {
|
||||
if(rootAtribs[j].indexOf('xmlns:') === 0 &&
|
||||
doc.getroot().attrib[rootAtribs[j]] === 'http://cordova.apache.org/ns/1.0'){
|
||||
for (var j = 0; j < rootAtribs.length; j++) {
|
||||
if (rootAtribs[j].indexOf('xmlns:') === 0 &&
|
||||
doc.getroot().attrib[rootAtribs[j]] === 'http://cordova.apache.org/ns/1.0') {
|
||||
var strings = rootAtribs[j].split(':');
|
||||
prefix = strings[1];
|
||||
break;
|
||||
@@ -76,7 +73,7 @@ function getCordovaNamespacePrefix(doc){
|
||||
* @param {Array} elems An array of ElementTree nodes
|
||||
* @return {String}
|
||||
*/
|
||||
function findElementAttributeValue(attributeName, elems) {
|
||||
function findElementAttributeValue (attributeName, elems) {
|
||||
|
||||
elems = Array.isArray(elems) ? elems : [ elems ];
|
||||
|
||||
@@ -86,69 +83,69 @@ function findElementAttributeValue(attributeName, elems) {
|
||||
return filteredElems.attrib.value;
|
||||
}).pop();
|
||||
|
||||
return value ? value : '';
|
||||
return value || '';
|
||||
}
|
||||
|
||||
ConfigParser.prototype = {
|
||||
getAttribute: function(attr) {
|
||||
getAttribute: function (attr) {
|
||||
return this.doc.getroot().attrib[attr];
|
||||
},
|
||||
|
||||
packageName: function(id) {
|
||||
packageName: function (id) {
|
||||
return this.getAttribute('id');
|
||||
},
|
||||
setPackageName: function(id) {
|
||||
setPackageName: function (id) {
|
||||
this.doc.getroot().attrib['id'] = id;
|
||||
},
|
||||
android_packageName: function() {
|
||||
android_packageName: function () {
|
||||
return this.getAttribute('android-packageName');
|
||||
},
|
||||
android_activityName: function() {
|
||||
android_activityName: function () {
|
||||
return this.getAttribute('android-activityName');
|
||||
},
|
||||
ios_CFBundleIdentifier: function() {
|
||||
ios_CFBundleIdentifier: function () {
|
||||
return this.getAttribute('ios-CFBundleIdentifier');
|
||||
},
|
||||
name: function() {
|
||||
name: function () {
|
||||
return getNodeTextSafe(this.doc.find('name'));
|
||||
},
|
||||
setName: function(name) {
|
||||
setName: function (name) {
|
||||
var el = findOrCreate(this.doc, 'name');
|
||||
el.text = name;
|
||||
},
|
||||
shortName: function() {
|
||||
shortName: function () {
|
||||
return this.doc.find('name').attrib['short'] || this.name();
|
||||
},
|
||||
setShortName: function(shortname) {
|
||||
setShortName: function (shortname) {
|
||||
var el = findOrCreate(this.doc, 'name');
|
||||
if (!el.text) {
|
||||
el.text = shortname;
|
||||
}
|
||||
el.attrib['short'] = shortname;
|
||||
},
|
||||
description: function() {
|
||||
description: function () {
|
||||
return getNodeTextSafe(this.doc.find('description'));
|
||||
},
|
||||
setDescription: function(text) {
|
||||
setDescription: function (text) {
|
||||
var el = findOrCreate(this.doc, 'description');
|
||||
el.text = text;
|
||||
},
|
||||
version: function() {
|
||||
version: function () {
|
||||
return this.getAttribute('version');
|
||||
},
|
||||
windows_packageVersion: function() {
|
||||
windows_packageVersion: function () {
|
||||
return this.getAttribute('windows-packageVersion');
|
||||
},
|
||||
android_versionCode: function() {
|
||||
android_versionCode: function () {
|
||||
return this.getAttribute('android-versionCode');
|
||||
},
|
||||
ios_CFBundleVersion: function() {
|
||||
ios_CFBundleVersion: function () {
|
||||
return this.getAttribute('ios-CFBundleVersion');
|
||||
},
|
||||
setVersion: function(value) {
|
||||
setVersion: function (value) {
|
||||
this.doc.getroot().attrib['version'] = value;
|
||||
},
|
||||
author: function() {
|
||||
author: function () {
|
||||
return getNodeTextSafe(this.doc.find('author'));
|
||||
},
|
||||
getGlobalPreference: function (name) {
|
||||
@@ -166,7 +163,7 @@ ConfigParser.prototype = {
|
||||
getPlatformPreference: function (name, platform) {
|
||||
return findElementAttributeValue(name, this.doc.findall('platform[@name=\'' + platform + '\']/preference'));
|
||||
},
|
||||
getPreference: function(name, platform) {
|
||||
getPreference: function (name, platform) {
|
||||
|
||||
var platformPreference = '';
|
||||
|
||||
@@ -174,7 +171,7 @@ ConfigParser.prototype = {
|
||||
platformPreference = this.getPlatformPreference(name, platform);
|
||||
}
|
||||
|
||||
return platformPreference ? platformPreference : this.getGlobalPreference(name);
|
||||
return platformPreference || this.getGlobalPreference(name);
|
||||
|
||||
},
|
||||
/**
|
||||
@@ -184,11 +181,11 @@ ConfigParser.prototype = {
|
||||
* "icon" and "splash" currently supported.
|
||||
* @return {Array} Resources for the platform specified.
|
||||
*/
|
||||
getStaticResources: function(platform, resourceName) {
|
||||
var ret = [],
|
||||
staticResources = [];
|
||||
getStaticResources: function (platform, resourceName) {
|
||||
var ret = [];
|
||||
var staticResources = [];
|
||||
if (platform) { // platform specific icons
|
||||
this.doc.findall('platform[@name=\'' + platform + '\']/' + resourceName).forEach(function(elt){
|
||||
this.doc.findall('platform[@name=\'' + platform + '\']/' + resourceName).forEach(function (elt) {
|
||||
elt.platform = platform; // mark as platform specific resource
|
||||
staticResources.push(elt);
|
||||
});
|
||||
@@ -201,7 +198,7 @@ ConfigParser.prototype = {
|
||||
var res = {};
|
||||
res.src = elt.attrib.src;
|
||||
res.target = elt.attrib.target || undefined;
|
||||
res.density = elt.attrib['density'] || elt.attrib[that.cdvNamespacePrefix+':density'] || elt.attrib['gap:density'];
|
||||
res.density = elt.attrib['density'] || elt.attrib[that.cdvNamespacePrefix + ':density'] || elt.attrib['gap:density'];
|
||||
res.platform = elt.platform || null; // null means icon represents default icon (shared between platforms)
|
||||
res.width = +elt.attrib.width || undefined;
|
||||
res.height = +elt.attrib.height || undefined;
|
||||
@@ -219,13 +216,13 @@ ConfigParser.prototype = {
|
||||
* @param {number} height Height of resource.
|
||||
* @return {Resource} Resource object or null if not found.
|
||||
*/
|
||||
ret.getBySize = function(width, height) {
|
||||
return ret.filter(function(res) {
|
||||
ret.getBySize = function (width, height) {
|
||||
return ret.filter(function (res) {
|
||||
if (!res.width && !res.height) {
|
||||
return false;
|
||||
}
|
||||
return ((!res.width || (width == res.width)) &&
|
||||
(!res.height || (height == res.height)));
|
||||
return ((!res.width || (width === res.width)) &&
|
||||
(!res.height || (height === res.height)));
|
||||
})[0] || null;
|
||||
};
|
||||
|
||||
@@ -234,14 +231,14 @@ ConfigParser.prototype = {
|
||||
* @param {string} density Density of resource.
|
||||
* @return {Resource} Resource object or null if not found.
|
||||
*/
|
||||
ret.getByDensity = function(density) {
|
||||
return ret.filter(function(res) {
|
||||
return res.density == density;
|
||||
ret.getByDensity = function (density) {
|
||||
return ret.filter(function (res) {
|
||||
return res.density === density;
|
||||
})[0] || null;
|
||||
};
|
||||
|
||||
/** Returns default icons */
|
||||
ret.getDefault = function() {
|
||||
ret.getDefault = function () {
|
||||
return ret.defaultResource;
|
||||
};
|
||||
|
||||
@@ -253,7 +250,7 @@ ConfigParser.prototype = {
|
||||
* @param {string} platform Platform name
|
||||
* @return {Resource[]} Array of icon objects.
|
||||
*/
|
||||
getIcons: function(platform) {
|
||||
getIcons: function (platform) {
|
||||
return this.getStaticResources(platform, 'icon');
|
||||
},
|
||||
|
||||
@@ -262,20 +259,22 @@ ConfigParser.prototype = {
|
||||
* @param {string} platform Platform name
|
||||
* @return {Resource[]} Array of Splash objects.
|
||||
*/
|
||||
getSplashScreens: function(platform) {
|
||||
getSplashScreens: function (platform) {
|
||||
return this.getStaticResources(platform, 'splash');
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
fileResources = this.doc.findall('platform[@name=\'' + platform + '\']/resource-file').map(function(tag) {
|
||||
fileResources = this.doc.findall('platform[@name=\'' + platform + '\']/resource-file').map(function (tag) {
|
||||
return {
|
||||
platform: platform,
|
||||
src: tag.attrib.src,
|
||||
@@ -287,6 +286,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;
|
||||
},
|
||||
|
||||
@@ -296,23 +308,23 @@ ConfigParser.prototype = {
|
||||
* @param {Array} platforms Platforms to look for scripts into (root scripts will be included as well).
|
||||
* @return {Array} Script elements.
|
||||
*/
|
||||
getHookScripts: function(hook, platforms) {
|
||||
getHookScripts: function (hook, platforms) {
|
||||
var self = this;
|
||||
var scriptElements = self.doc.findall('./hook');
|
||||
|
||||
if(platforms) {
|
||||
if (platforms) {
|
||||
platforms.forEach(function (platform) {
|
||||
scriptElements = scriptElements.concat(self.doc.findall('./platform[@name="' + platform + '"]/hook'));
|
||||
});
|
||||
}
|
||||
|
||||
function filterScriptByHookType(el) {
|
||||
function filterScriptByHookType (el) {
|
||||
return el.attrib.src && el.attrib.type && el.attrib.type.toLowerCase() === hook;
|
||||
}
|
||||
|
||||
return scriptElements.filter(filterScriptByHookType);
|
||||
},
|
||||
/**
|
||||
/**
|
||||
* Returns a list of plugin (IDs).
|
||||
*
|
||||
* This function also returns any plugin's that
|
||||
@@ -321,13 +333,13 @@ ConfigParser.prototype = {
|
||||
*/
|
||||
getPluginIdList: function () {
|
||||
var plugins = this.doc.findall('plugin');
|
||||
var result = plugins.map(function(plugin){
|
||||
var result = plugins.map(function (plugin) {
|
||||
return plugin.attrib.name;
|
||||
});
|
||||
var features = this.doc.findall('feature');
|
||||
features.forEach(function(element ){
|
||||
features.forEach(function (element) {
|
||||
var idTag = element.find('./param[@name="id"]');
|
||||
if(idTag){
|
||||
if (idTag) {
|
||||
result.push(idTag.attrib.value);
|
||||
}
|
||||
});
|
||||
@@ -356,9 +368,9 @@ ConfigParser.prototype = {
|
||||
// support arbitrary object as variables source
|
||||
if (variables && typeof variables === 'object' && !Array.isArray(variables)) {
|
||||
variables = Object.keys(variables)
|
||||
.map(function (variableName) {
|
||||
return {name: variableName, value: variables[variableName]};
|
||||
});
|
||||
.map(function (variableName) {
|
||||
return {name: variableName, value: variables[variableName]};
|
||||
});
|
||||
}
|
||||
|
||||
if (variables) {
|
||||
@@ -378,15 +390,15 @@ ConfigParser.prototype = {
|
||||
* @param {String} id
|
||||
* @returns {object} plugin including any variables
|
||||
*/
|
||||
getPlugin: function(id){
|
||||
if(!id){
|
||||
getPlugin: function (id) {
|
||||
if (!id) {
|
||||
return undefined;
|
||||
}
|
||||
var pluginElement = this.doc.find('./plugin/[@name="' + id + '"]');
|
||||
if (null === pluginElement) {
|
||||
var legacyFeature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..');
|
||||
if(legacyFeature){
|
||||
events.emit('log', 'Found deprecated feature entry for ' + id +' in config.xml.');
|
||||
if (pluginElement === null) {
|
||||
var legacyFeature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..');
|
||||
if (legacyFeature) {
|
||||
events.emit('log', 'Found deprecated feature entry for ' + id + ' in config.xml.');
|
||||
return featureToPlugin(legacyFeature);
|
||||
}
|
||||
return undefined;
|
||||
@@ -397,10 +409,10 @@ ConfigParser.prototype = {
|
||||
plugin.spec = pluginElement.attrib.spec || pluginElement.attrib.src || pluginElement.attrib.version;
|
||||
plugin.variables = {};
|
||||
var variableElements = pluginElement.findall('variable');
|
||||
variableElements.forEach(function(varElement){
|
||||
variableElements.forEach(function (varElement) {
|
||||
var name = varElement.attrib.name;
|
||||
var value = varElement.attrib.value;
|
||||
if(name){
|
||||
if (name) {
|
||||
plugin.variables[name] = value;
|
||||
}
|
||||
});
|
||||
@@ -415,8 +427,8 @@ ConfigParser.prototype = {
|
||||
* @function
|
||||
* @param id name of the plugin
|
||||
*/
|
||||
removePlugin: function(id){
|
||||
if(id){
|
||||
removePlugin: function (id) {
|
||||
if (id) {
|
||||
var plugins = this.doc.findall('./plugin/[@name="' + id + '"]')
|
||||
.concat(this.doc.findall('./feature/param[@name="id"][@value="' + id + '"]/..'));
|
||||
var children = this.doc.getroot().getchildren();
|
||||
@@ -430,7 +442,7 @@ ConfigParser.prototype = {
|
||||
},
|
||||
|
||||
// Add any element to the root
|
||||
addElement: function(name, attributes) {
|
||||
addElement: function (name, attributes) {
|
||||
var el = et.Element(name);
|
||||
for (var a in attributes) {
|
||||
el.attrib[a] = attributes[a];
|
||||
@@ -443,11 +455,11 @@ ConfigParser.prototype = {
|
||||
* @param {String} name the engine name
|
||||
* @param {String} spec engine source location or version (optional)
|
||||
*/
|
||||
addEngine: function(name, spec){
|
||||
if(!name) return;
|
||||
addEngine: function (name, spec) {
|
||||
if (!name) return;
|
||||
var el = et.Element('engine');
|
||||
el.attrib.name = name;
|
||||
if(spec){
|
||||
if (spec) {
|
||||
el.attrib.spec = spec;
|
||||
}
|
||||
this.doc.getroot().append(el);
|
||||
@@ -456,52 +468,54 @@ ConfigParser.prototype = {
|
||||
* Removes all the engines with given name
|
||||
* @param {String} name the engine name.
|
||||
*/
|
||||
removeEngine: function(name){
|
||||
var engines = this.doc.findall('./engine/[@name="' +name+'"]');
|
||||
for(var i=0; i < engines.length; i++){
|
||||
removeEngine: function (name) {
|
||||
var engines = this.doc.findall('./engine/[@name="' + name + '"]');
|
||||
for (var i = 0; i < engines.length; i++) {
|
||||
var children = this.doc.getroot().getchildren();
|
||||
var idx = children.indexOf(engines[i]);
|
||||
if(idx > -1){
|
||||
children.splice(idx,1);
|
||||
if (idx > -1) {
|
||||
children.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
getEngines: function(){
|
||||
getEngines: function () {
|
||||
var engines = this.doc.findall('./engine');
|
||||
return engines.map(function(engine){
|
||||
return engines.map(function (engine) {
|
||||
var spec = engine.attrib.spec || engine.attrib.version;
|
||||
return {
|
||||
'name': engine.attrib.name,
|
||||
'spec': spec ? spec : null
|
||||
'spec': spec || null
|
||||
};
|
||||
});
|
||||
},
|
||||
/* Get all the access tags */
|
||||
getAccesses: function() {
|
||||
getAccesses: function () {
|
||||
var accesses = this.doc.findall('./access');
|
||||
return accesses.map(function(access){
|
||||
return accesses.map(function (access) {
|
||||
var minimum_tls_version = access.attrib['minimum-tls-version']; /* String */
|
||||
var requires_forward_secrecy = access.attrib['requires-forward-secrecy']; /* Boolean */
|
||||
var requires_certificate_transparency = access.attrib['requires-certificate-transparency']; /* Boolean */
|
||||
var allows_arbitrary_loads_in_web_content = access.attrib['allows-arbitrary-loads-in-web-content']; /* Boolean */
|
||||
var allows_arbitrary_loads_in_media = access.attrib['allows-arbitrary-loads-in-media']; /* Boolean */
|
||||
var allows_arbitrary_loads_in_media = access.attrib['allows-arbitrary-loads-in-media']; /* Boolean (DEPRECATED) */
|
||||
var allows_arbitrary_loads_for_media = access.attrib['allows-arbitrary-loads-for-media']; /* Boolean */
|
||||
var allows_local_networking = access.attrib['allows-local-networking']; /* Boolean */
|
||||
|
||||
|
||||
return {
|
||||
'origin': access.attrib.origin,
|
||||
'minimum_tls_version': minimum_tls_version,
|
||||
'requires_forward_secrecy' : requires_forward_secrecy,
|
||||
'requires_certificate_transparency' : requires_certificate_transparency,
|
||||
'allows_arbitrary_loads_in_web_content' : allows_arbitrary_loads_in_web_content,
|
||||
'allows_arbitrary_loads_in_media' : allows_arbitrary_loads_in_media,
|
||||
'allows_local_networking' : allows_local_networking
|
||||
'requires_forward_secrecy': requires_forward_secrecy,
|
||||
'requires_certificate_transparency': requires_certificate_transparency,
|
||||
'allows_arbitrary_loads_in_web_content': allows_arbitrary_loads_in_web_content,
|
||||
'allows_arbitrary_loads_in_media': allows_arbitrary_loads_in_media,
|
||||
'allows_arbitrary_loads_for_media': allows_arbitrary_loads_for_media,
|
||||
'allows_local_networking': allows_local_networking
|
||||
};
|
||||
});
|
||||
},
|
||||
/* Get all the allow-navigation tags */
|
||||
getAllowNavigations: function() {
|
||||
getAllowNavigations: function () {
|
||||
var allow_navigations = this.doc.findall('./allow-navigation');
|
||||
return allow_navigations.map(function(allow_navigation){
|
||||
return allow_navigations.map(function (allow_navigation) {
|
||||
var minimum_tls_version = allow_navigation.attrib['minimum-tls-version']; /* String */
|
||||
var requires_forward_secrecy = allow_navigation.attrib['requires-forward-secrecy']; /* Boolean */
|
||||
var requires_certificate_transparency = allow_navigation.attrib['requires-certificate-transparency']; /* Boolean */
|
||||
@@ -509,45 +523,68 @@ ConfigParser.prototype = {
|
||||
return {
|
||||
'href': allow_navigation.attrib.href,
|
||||
'minimum_tls_version': minimum_tls_version,
|
||||
'requires_forward_secrecy' : requires_forward_secrecy,
|
||||
'requires_certificate_transparency' : requires_certificate_transparency
|
||||
'requires_forward_secrecy': requires_forward_secrecy,
|
||||
'requires_certificate_transparency': requires_certificate_transparency
|
||||
};
|
||||
});
|
||||
},
|
||||
/* Get all the allow-intent tags */
|
||||
getAllowIntents: function() {
|
||||
getAllowIntents: function () {
|
||||
var allow_intents = this.doc.findall('./allow-intent');
|
||||
return allow_intents.map(function(allow_intent){
|
||||
return allow_intents.map(function (allow_intent) {
|
||||
return {
|
||||
'href': allow_intent.attrib.href
|
||||
};
|
||||
});
|
||||
},
|
||||
/* Get all edit-config tags */
|
||||
getEditConfigs: function(platform) {
|
||||
getEditConfigs: function (platform) {
|
||||
var platform_tag = this.doc.find('./platform[@name="' + platform + '"]');
|
||||
var platform_edit_configs = platform_tag ? platform_tag.findall('edit-config') : [];
|
||||
|
||||
var edit_configs = this.doc.findall('edit-config').concat(platform_edit_configs);
|
||||
|
||||
return edit_configs.map(function(tag) {
|
||||
return edit_configs.map(function (tag) {
|
||||
var editConfig =
|
||||
{
|
||||
file : tag.attrib['file'],
|
||||
target : tag.attrib['target'],
|
||||
mode : tag.attrib['mode'],
|
||||
id : 'config.xml',
|
||||
xmls : tag.getchildren()
|
||||
file: tag.attrib['file'],
|
||||
target: tag.attrib['target'],
|
||||
mode: tag.attrib['mode'],
|
||||
id: 'config.xml',
|
||||
xmls: tag.getchildren()
|
||||
};
|
||||
return editConfig;
|
||||
});
|
||||
},
|
||||
write:function() {
|
||||
|
||||
/* Get all config-file tags */
|
||||
getConfigFiles: function (platform) {
|
||||
var platform_tag = this.doc.find('./platform[@name="' + platform + '"]');
|
||||
var platform_config_files = platform_tag ? platform_tag.findall('config-file') : [];
|
||||
|
||||
var config_files = this.doc.findall('config-file').concat(platform_config_files);
|
||||
|
||||
return config_files.map(function (tag) {
|
||||
var configFile =
|
||||
{
|
||||
target: tag.attrib['target'],
|
||||
parent: tag.attrib['parent'],
|
||||
after: tag.attrib['after'],
|
||||
xmls: tag.getchildren(),
|
||||
// To support demuxing via versions
|
||||
versions: tag.attrib['versions'],
|
||||
deviceTarget: tag.attrib['device-target']
|
||||
};
|
||||
return configFile;
|
||||
});
|
||||
},
|
||||
|
||||
write: function () {
|
||||
fs.writeFileSync(this.path, this.doc.write({indent: 4}), 'utf-8');
|
||||
}
|
||||
};
|
||||
|
||||
function featureToPlugin(featureElement) {
|
||||
function featureToPlugin (featureElement) {
|
||||
var plugin = {};
|
||||
plugin.variables = [];
|
||||
var pluginVersion,
|
||||
|
||||
Reference in New Issue
Block a user