Skip to content

Commit

Permalink
FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
dpa99c committed Nov 22, 2023
1 parent b890c0a commit 6cd9bb5
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/ios/local-receipt-validation/apply-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,19 @@ const parsePluginVariables = function(){

// Parse config.xml
const config = parseConfigXml();
(config.widget.plugin ? [].concat(config.widget.plugin) : []).forEach(function(plugin){
(plugin.variable ? [].concat(plugin.variable) : []).forEach(function(variable){
if((plugin._attributes.name === PLUGIN_ID || plugin._attributes.id === PLUGIN_ID) && variable._attributes.name && variable._attributes.value){
pluginVariables[variable._attributes.name] = variable._attributes.value;
}
if(config) {
(config.widget.plugin ? [].concat(config.widget.plugin) : []).forEach(function (plugin) {
(plugin.variable ? [].concat(plugin.variable) : []).forEach(function (variable) {
if ((plugin._attributes.name === PLUGIN_ID || plugin._attributes.id === PLUGIN_ID) && variable._attributes.name && variable._attributes.value) {
pluginVariables[variable._attributes.name] = variable._attributes.value;
}
});
});
});
}

// Parse package.json
const packageJSON = parsePackageJson();
if(packageJSON.cordova && packageJSON.cordova.plugins){
if(packageJSON && packageJSON.cordova && packageJSON.cordova.plugins){
for(const pluginId in packageJSON.cordova.plugins){
if(pluginId === PLUGIN_ID){
for(const varName in packageJSON.cordova.plugins[pluginId]){
Expand All @@ -157,15 +159,23 @@ const parsePluginVariables = function(){

const parsePackageJson = function(){
if(projectPackageJsonData) return projectPackageJsonData;
projectPackageJsonData = JSON.parse(fs.readFileSync(projectPackageJsonPath));
return projectPackageJsonData;
try{
projectPackageJsonData = JSON.parse(fs.readFileSync(projectPackageJsonPath));
return projectPackageJsonData;
}catch(e){
console.warn("Failed to parse package.json: " + e.message);
}
};

const parseConfigXml = function(){
if(configXmlData) return configXmlData;
data = parseXmlFileToJson(configXmlPath);
configXmlData = data.xml;
return configXmlData;
try{
data = parseXmlFileToJson(configXmlPath);
configXmlData = data.xml;
return configXmlData;
}catch (e){
console.warn("Failed to parse config.xml: " + e.message);
}
};

const parsePluginXml = function(){
Expand Down

0 comments on commit 6cd9bb5

Please sign in to comment.