fix(maker): fix detection of flatpak artifact

This commit is contained in:
Mark Lee 2017-12-06 18:22:22 -08:00 коммит произвёл Samuel Attard
Родитель 9c199e0dd4
Коммит 4d5378c221
2 изменённых файлов: 16 добавлений и 9 удалений

Просмотреть файл

@ -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;