Skip to content
Permalink
Browse files

fix(maker): fix detection of flatpak artifact

  • Loading branch information
malept authored and MarshallOfSound committed Dec 7, 2017
1 parent 9c199e0 commit 4d5378c2219b1d8a7643fe85128a395c3fca8c8c
Showing with 16 additions and 9 deletions.
  1. +12 −6 src/makers/linux/flatpak.js
  2. +4 −3 test/fast/makers/flatpak_spec.js
@@ -1,7 +1,8 @@
import fs from 'fs-extra';
import path from 'path';
import pify from 'pify';

import { ensureFile } from '../../util/ensure-output';
import { ensureDirectory } from '../../util/ensure-output';
import isInstalled from '../../util/is-installed';
import { linuxConfig, populateConfig } from '../../util/linux-config';

@@ -17,21 +18,26 @@ export function flatpakArch(nodeArch) {
}
}

export default async ({ dir, targetArch, forgeConfig, packageJSON }) => {
export default async ({ dir, targetArch, forgeConfig }) => {
const installer = require('electron-installer-flatpak');

const arch = flatpakArch(targetArch);
const config = populateConfig({ forgeConfig, configKey: 'electronInstallerFlatpak', targetArch });
const outPath = path.resolve(dir, '../make', `${packageJSON.name}_${packageJSON.version}_${arch}.flatpak`);
const outDir = path.resolve(dir, '../make');

await ensureFile(outPath);
await ensureDirectory(outDir);
const flatpakConfig = linuxConfig({
config,
pkgArch: arch,
dir,
outPath,
// electron-installer-flatpak uses a filename scheme with default config options that we don't
// have access to, so we need to detect the flatpak filename after it's created.
outPath: path.join(outDir, 'dummy.flatpak'),
});

await pify(installer)(flatpakConfig);
return [outPath];

return (await fs.readdir(outDir))
.filter(basename => basename.endsWith('.flatpak'))
.map(basename => path.join(outDir, basename));
};
@@ -10,7 +10,7 @@ describe('flatpak maker', () => {
let flatpakModule;
let flatpakMaker;
let eidStub;
let ensureFileStub;
let ensureDirectoryStub;
let forgeConfig;

const dir = '/my/test/dir/out';
@@ -19,13 +19,14 @@ describe('flatpak maker', () => {
const packageJSON = { version: '1.2.3' };

beforeEach(() => {
ensureFileStub = stub().returns(Promise.resolve());
ensureDirectoryStub = stub().returns(Promise.resolve());
eidStub = stub().callsArg(1);
forgeConfig = { electronInstallerFlatpak: {} };

flatpakModule = proxyquire.noPreserveCache().noCallThru().load('../../../src/makers/linux/flatpak', {
'fs-extra': { readdir: stub().returns(Promise.resolve([])) },
'./config-fn': config => config,
'../../util/ensure-output': { ensureFile: ensureFileStub },
'../../util/ensure-output': { ensureDirectory: ensureDirectoryStub },
'electron-installer-flatpak': eidStub,
});
flatpakMaker = flatpakModule.default;

0 comments on commit 4d5378c

Please sign in to comment.
You can’t perform that action at this time.