Skip to content

Commit

Permalink
fix: handle missing manifest in zip maker
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Nov 9, 2023
1 parent fd00d9a commit b626ab8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/maker/zip/src/MakerZIP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export default class MakerZIP extends MakerBase<MakerZIPConfig> {
if (targetPlatform === 'darwin' && this.config.macUpdateManifestBaseUrl) {
const parsed = new URL(this.config.macUpdateManifestBaseUrl);
parsed.pathname += '/RELEASES.json';
const response = await got.get(parsed.toString());
const response = await got.get(parsed.toString(), {
throwHttpErrors: false,
});
let currentValue: SquirrelMacReleases = {
currentRelease: '',
releases: [],
Expand Down
24 changes: 24 additions & 0 deletions packages/maker/zip/test/MakerZip_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@ describe('MakerZip', () => {
expect(foo.releases[0].updateTo).to.have.property('url');
});

it('should generate a valid RELEASES.json manifest with no current file', async () => {
maker.config = {
macUpdateManifestBaseUrl: 'fake://test/foo',
};
getStub.returns(Promise.resolve({ statusCode: 404, body: 'GARBAGE' }));
const output = await maker.make({
dir: darwinDir,
makeDir,
appName,
targetArch,
targetPlatform: 'darwin',
packageJSON,
forgeConfig: null as any,
});

const foo = await fs.readJson(output[1]);
expect(foo).to.have.property('currentRelease', '1.2.3');
expect(foo).to.have.property('releases');
expect(foo.releases).to.be.an('array').with.lengthOf(1);
expect(foo.releases[0]).to.have.property('version');
expect(foo.releases[0]).to.have.property('updateTo');
expect(foo.releases[0].updateTo).to.have.property('url');
});

it('should extend the current RELEASES.json manifest if it exists', async () => {
maker.config = {
macUpdateManifestBaseUrl: 'fake://test/foo',
Expand Down

0 comments on commit b626ab8

Please sign in to comment.