Skip to content

Commit

Permalink
fix: add check when converting/assigning image
Browse files Browse the repository at this point in the history
Signed-off-by: lstocchi <lstocchi@redhat.com>
  • Loading branch information
lstocchi committed Aug 2, 2023
1 parent d3670ee commit e128e95
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions packages/main/src/plugin/onboarding-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,27 @@ export class OnboardingRegistry {

convertImages(extension: AnalyzedExtension, onboarding: Onboarding) {
if (onboarding.media?.path) {
onboarding.media.path = getBase64Image(path.resolve(extension.path, onboarding.media.path));
const base64Image = getBase64Image(path.resolve(extension.path, onboarding.media.path));
if (base64Image) {
onboarding.media.path = base64Image;
}
} else if (extension.manifest?.icon) {
// if no image has been set for the onboarding, it uses the extension icon
onboarding.media = {
path: getBase64Image(path.resolve(extension.path, extension.manifest.icon)),
altText: 'icon',
};
const base64Image = getBase64Image(path.resolve(extension.path, extension.manifest.icon));
if (base64Image) {
// if no image has been set for the onboarding, it uses the extension icon
onboarding.media = {
path: base64Image,
altText: 'icon',
};
}
}

for (const step of onboarding.steps) {
if (step.media?.path) {
step.media.path = getBase64Image(path.resolve(extension.path, step.media.path));
const base64Image = getBase64Image(path.resolve(extension.path, step.media.path));
if (base64Image) {
step.media.path = base64Image;
}
}
}
}
Expand Down

0 comments on commit e128e95

Please sign in to comment.