Skip to content

Commit

Permalink
fix: ignore version not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
gera2ld committed Sep 25, 2023
1 parent 564a473 commit c4fefc8
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,27 +311,34 @@ export async function signAddon({
}: SignAddonParam) {
const client = new AMOClient(apiKey, apiSecret, apiPrefix);

let versionInfo = await client.getVersion(addonId, addonVersion);
const isNewVersion = !versionInfo;
if (!versionInfo) {
let versionDetail: VersionDetail | undefined;
try {
versionDetail = await client.getVersion(addonId, addonVersion);
} catch (err) {
if ((err as { res: Response })?.res?.status !== 404) {
throw err;
}
}
const isNewVersion = !versionDetail;
if (!versionDetail) {
if (!distFile)
throw new Error('Version not found, please provide distFile');
versionInfo = await client.createVersion(addonId, channel, distFile, {
versionDetail = await client.createVersion(addonId, channel, distFile, {
sourceFile,
approvalNotes,
releaseNotes,
});
} else {
versionInfo = await client.updateVersion(addonId, versionInfo, {
versionDetail = await client.updateVersion(addonId, versionDetail, {
sourceFile,
approvalNotes,
releaseNotes,
overrideNotes,
});
}
if (!output && channel === 'listed') {
return versionInfo.file.url.slice(
versionInfo.file.url.lastIndexOf('/') + 1,
return versionDetail.file.url.slice(
versionDetail.file.url.lastIndexOf('/') + 1,
);
}

Expand Down

0 comments on commit c4fefc8

Please sign in to comment.