Skip to content

Commit e1cc096

Browse files
authored
fix: plugin podspec with no config elements (#1067)
1 parent ffdcc5a commit e1cc096

File tree

1 file changed

+47
-39
lines changed
  • bin/templates/scripts/cordova

1 file changed

+47
-39
lines changed

bin/templates/scripts/cordova/Api.js

+47-39
Original file line numberDiff line numberDiff line change
@@ -354,52 +354,60 @@ Api.prototype.addPodSpecs = function (plugin, podSpecs, frameworkPods, installOp
354354
events.emit('verbose', 'Adding pods since the plugin contained <podspecs>');
355355
podSpecs.forEach(obj => {
356356
// declarations
357-
Object.keys(obj.declarations).forEach(key => {
358-
if (obj.declarations[key] === 'true') {
359-
const declaration = Podfile.proofDeclaration(key);
357+
if (obj.declarations) {
358+
Object.keys(obj.declarations).forEach(key => {
359+
if (obj.declarations[key] === 'true') {
360+
const declaration = Podfile.proofDeclaration(key);
361+
const podJson = {
362+
declaration
363+
};
364+
const val = podsjsonFile.getDeclaration(declaration);
365+
if (val) {
366+
podsjsonFile.incrementDeclaration(declaration);
367+
} else {
368+
podJson.count = 1;
369+
podsjsonFile.setJsonDeclaration(declaration, podJson);
370+
podfileFile.addDeclaration(podJson.declaration);
371+
}
372+
}
373+
});
374+
}
375+
376+
// sources
377+
if (obj.sources) {
378+
Object.keys(obj.sources).forEach(key => {
360379
const podJson = {
361-
declaration
380+
source: obj.sources[key].source
362381
};
363-
const val = podsjsonFile.getDeclaration(declaration);
382+
const val = podsjsonFile.getSource(key);
364383
if (val) {
365-
podsjsonFile.incrementDeclaration(declaration);
384+
podsjsonFile.incrementSource(key);
366385
} else {
367386
podJson.count = 1;
368-
podsjsonFile.setJsonDeclaration(declaration, podJson);
369-
podfileFile.addDeclaration(podJson.declaration);
387+
podsjsonFile.setJsonSource(key, podJson);
388+
podfileFile.addSource(podJson.source);
370389
}
371-
}
372-
});
373-
// sources
374-
Object.keys(obj.sources).forEach(key => {
375-
const podJson = {
376-
source: obj.sources[key].source
377-
};
378-
const val = podsjsonFile.getSource(key);
379-
if (val) {
380-
podsjsonFile.incrementSource(key);
381-
} else {
382-
podJson.count = 1;
383-
podsjsonFile.setJsonSource(key, podJson);
384-
podfileFile.addSource(podJson.source);
385-
}
386-
});
390+
});
391+
}
392+
387393
// libraries
388-
Object.keys(obj.libraries).forEach(key => {
389-
const podJson = Object.assign({}, obj.libraries[key]);
390-
if (podJson.spec) {
391-
podJson.spec = getVariableSpec(podJson.spec, installOptions);
392-
}
393-
const val = podsjsonFile.getLibrary(key);
394-
if (val) {
395-
events.emit('warn', `${plugin.id} depends on ${podJson.name}, which may conflict with another plugin. ${podJson.name}@${val.spec} is already installed and was not overwritten.`);
396-
podsjsonFile.incrementLibrary(key);
397-
} else {
398-
podJson.count = 1;
399-
podsjsonFile.setJsonLibrary(key, podJson);
400-
podfileFile.addSpec(podJson.name, podJson);
401-
}
402-
});
394+
if (obj.libraries) {
395+
Object.keys(obj.libraries).forEach(key => {
396+
const podJson = Object.assign({}, obj.libraries[key]);
397+
if (podJson.spec) {
398+
podJson.spec = getVariableSpec(podJson.spec, installOptions);
399+
}
400+
const val = podsjsonFile.getLibrary(key);
401+
if (val) {
402+
events.emit('warn', `${plugin.id} depends on ${podJson.name}, which may conflict with another plugin. ${podJson.name}@${val.spec} is already installed and was not overwritten.`);
403+
podsjsonFile.incrementLibrary(key);
404+
} else {
405+
podJson.count = 1;
406+
podsjsonFile.setJsonLibrary(key, podJson);
407+
podfileFile.addSpec(podJson.name, podJson);
408+
}
409+
});
410+
}
403411
});
404412
}
405413

0 commit comments

Comments
 (0)