All files / makers/linux rpm.js

69.23% Statements 9/13
20% Branches 1/5
100% Functions 2/2
69.23% Lines 9/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32              1x   1x               1x 1x   1x 1x         1x   1x 1x    
import installer from 'electron-installer-redhat';
import path from 'path';
import pify from 'pify';
 
import { ensureFile } from '../../util/ensure-output';
 
function rpmArch(nodeArch) {
  switch (nodeArch) {
    case 'ia32': return 'i386';
    case 'x64': return 'x86_64';
    case 'armv7l': return 'armv7hl';
    case 'arm': return 'armv6hl';
    default: return nodeArch;
  }
}
 
export default async (dir, appName, targetArch, forgeConfig, packageJSON) => { // eslint-disable-line
  const arch = rpmArch(targetArch);
  const outPath = path.resolve(dir, '../make', `${packageJSON.name}-${packageJSON.version}.${arch}.rpm`);
 
  await ensureFile(outPath);
  const rpmDefaults = {
    arch,
    dest: path.dirname(outPath),
    src: dir,
  };
  const rpmConfig = Object.assign({}, forgeConfig.electronInstallerRedhat, rpmDefaults);
 
  await pify(installer)(rpmConfig);
  return [outPath];
};