Skip to content

Commit

Permalink
fix:(STRF-8909) theme variation not applied with activate flag (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntario authored Jan 14, 2021
1 parent 7093748 commit 6830f15
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/stencil-push.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,25 @@ utils.getVariations = async (options) => {
storeHash,
});

if (!activate && activate !== undefined) {
// Activate the default variation
if (activate === true) {
return { ...options, variationId: variations[0].uuid };
}
// Activate the specified variation
if (activate !== undefined) {
const foundVariation = variations.find((item) => item.name === activate);

if (!foundVariation || !foundVariation.uuid) {
const availableOptionsStr = variations.map((item) => `${item.name}`).join(', ');
throw new Error(
`Invalid theme variation provided!. Available options ${availableOptionsStr}...`,
`Invalid theme variation provided! Available options: ${availableOptionsStr}.`,
);
}

return { ...options, variationId: foundVariation.uuid };
}
if (activate) {
return { ...options, variationId: variations[0].uuid };
}

// Didn't specify a variation explicitly, will ask the user later
return { ...options, variations };
};

Expand Down

0 comments on commit 6830f15

Please sign in to comment.