Skip to content

Commit

Permalink
Fix: replace of podspec variables in podfile
Browse files Browse the repository at this point in the history
  • Loading branch information
filipepereira-ag authored and dpogue committed Jun 7, 2023
1 parent 76e33d9 commit 763884e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ function getVariableSpec (spec, options) {
return spec.includes('$') ? options.cli_variables[spec.replace('$', '')] : spec;
}

// Replaces all pod specs available
function replacePodSpecVariables (pod, options) {
const podSpecs = ['spec', 'tag', 'git', 'commit', 'branch'];

podSpecs.filter(e => pod[e])
.forEach(obj => {
const value = pod[obj];
pod[obj] = getVariableSpec(value, options);
});

return pod;
}

class Api {
/**
* Creates a new PlatformApi instance.
Expand Down Expand Up @@ -379,10 +392,8 @@ class Api {
// libraries
if (obj.libraries) {
Object.keys(obj.libraries).forEach(key => {
const podJson = Object.assign({}, obj.libraries[key]);
if (podJson.spec) {
podJson.spec = getVariableSpec(podJson.spec, installOptions);
}
let podJson = Object.assign({}, obj.libraries[key]);
podJson = replacePodSpecVariables(podJson, installOptions);
const val = podsjsonFile.getLibrary(key);
if (val) {
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.`);
Expand Down Expand Up @@ -472,10 +483,8 @@ class Api {
});
// libraries
Object.keys(obj.libraries).forEach(key => {
const podJson = Object.assign({}, obj.libraries[key]);
if (podJson.spec) {
podJson.spec = getVariableSpec(podJson.spec, uninstallOptions);
}
let podJson = Object.assign({}, obj.libraries[key]);
podJson = replacePodSpecVariables(podJson, uninstallOptions);
const val = podsjsonFile.getLibrary(key);
if (val) {
podsjsonFile.decrementLibrary(key);
Expand Down

0 comments on commit 763884e

Please sign in to comment.