Skip to content
Permalink
Browse files

refactor(installer): replace sudo-prompt with git branch of electron-…

…sudo for Linux installers
  • Loading branch information
malept authored and MarshallOfSound committed Dec 31, 2016
1 parent f8f9baa commit 9834cb1b4121b7dd517440cb389ef40d27b5d5e8
Showing with 23 additions and 16 deletions.
  1. +1 −0 package.json
  2. +2 −7 src/installers/linux/deb.js
  3. +2 −7 src/installers/linux/rpm.js
  4. +18 −2 src/util/linux-installer.js
@@ -66,6 +66,7 @@
"debug": "^2.3.3",
"electron-installer-dmg": "^0.1.2",
"electron-packager": "^8.4.0",
"electron-sudo": "malept/electron-sudo#fix-linux-sudo-detection",
"electron-winstaller": "^2.5.0",
"fs-promise": "^1.0.0",
"github": "^7.2.0",
@@ -1,10 +1,5 @@
import pify from 'pify';
import sudo from 'sudo-prompt';

import linuxInstaller from '../../util/linux-installer';
import { sudo } from '../../util/linux-installer';

export default async (filePath) => {
linuxInstaller('Debian', 'gdebi', pify(sudo.exec)(`gdebi -n ${filePath}`, {
name: 'Electron Forge',
}));
sudo('Debian', 'gdebi', `-n ${filePath}`);
};
@@ -1,10 +1,5 @@
import pify from 'pify';
import sudo from 'sudo-prompt';

import linuxInstaller from '../../util/linux-installer';
import { sudo } from '../../util/linux-installer';

export default async (filePath) => {
linuxInstaller('RPM', 'dnf', pify(sudo.exec)(`dnf --assumeyes --nogpgcheck install ${filePath}`, {
name: 'Electron Forge',
}));
sudo('RPM', 'dnf', `--assumeyes --nogpgcheck install ${filePath}`);
};
@@ -1,9 +1,25 @@
import { spawnSync } from 'child_process';
import { default as Sudoer } from 'electron-sudo';

export default async (type, prog, promise) => {
async function which(type, prog, promise) {
if (spawnSync('which', [prog]).status === 0) {
await promise;
} else {
throw new Error(`${prog} is required to install ${type} packages`);
}
};
}

async function sudo(type, prog, args) {
const sudoer = new Sudoer({ name: 'Electron Forge' });
which(type, prog, sudoer.spawn(`${prog} ${args}`).then((child) => {
child.on('exit', async (code) => {
if (code !== 0) {
console.error(child.output.stdout.toString('utf8'));
console.error(child.output.stderr.toString('utf8'));
throw new Error(`${prog} failed with status code ${code}`);
}
});
}));
}

export { which as default, sudo };

0 comments on commit 9834cb1

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