Skip to content

Commit

Permalink
Add a manifest warning when no icon is found
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding committed Feb 15, 2024
1 parent 7be3338 commit afc0a4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/snaps-utils/src/manifest/manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ describe('checkManifest', () => {
expect(warnings[0]).toMatch('Missing recommended package.json properties');
});

it('returns a warning if manifest has no defined icon', async () => {
const manifest = getSnapManifest();

// Remove icon
manifest.source.location.npm.iconPath = undefined;

await fs.writeFile(MANIFEST_PATH, JSON.stringify(manifest));

const { updated, warnings } = await checkManifest(BASE_PATH);
expect(updated).toBe(true);
expect(warnings).toHaveLength(1);
expect(warnings[0]).toMatch(
'No icon found in `source.location.npm.iconPath`. It is highly recommended for your Snap to have an icon.',
);
});

it('return errors if the manifest is invalid', async () => {
await fs.writeFile(
MANIFEST_PATH,
Expand Down
6 changes: 6 additions & 0 deletions packages/snaps-utils/src/manifest/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ export async function checkManifest(
);
}

if (!snapFiles.svgIcon) {
warnings.push(
'No icon found in `source.location.npm.iconPath`. It is highly recommended for your Snap to have an icon.',
);
}

if (writeManifest) {
try {
const newManifest = `${JSON.stringify(
Expand Down

0 comments on commit afc0a4b

Please sign in to comment.