Skip to content
Permalink
Browse files

refactor(installer): replace electron-sudo with sudo-prompt

Not worth using a branch of a Node module just for Promise support
for one platform.

ISSUES CLOSED: #58
  • Loading branch information
malept committed May 28, 2017
1 parent 33532f7 commit 0ea55fab4ea641408ba69c85a2409e4335950c1f
Showing with 3 additions and 17 deletions.
  1. +0 −1 package.json
  2. +3 −16 src/util/linux-installer.js
@@ -110,7 +110,6 @@
"electron-forge-template-vue": "^1.0.2",
"electron-packager": "^8.5.2",
"electron-rebuild": "^1.5.7",
"electron-sudo": "malept/electron-sudo#fix-linux-sudo-detection",
"form-data": "^2.1.4",
"fs-extra": "^3.0.0",
"github": "^9.0.0",
@@ -1,5 +1,6 @@
import { spawnSync } from 'child_process';
import Sudoer from 'electron-sudo';
import pify from 'pify';
import sudoPrompt from 'sudo-prompt';

const which = async (type, prog, promise) => {
if (spawnSync('which', [prog]).status === 0) {
@@ -10,20 +11,6 @@ const which = async (type, prog, promise) => {
};

export const sudo = (type, prog, args) =>
new Promise((resolve, reject) => {
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').red);
console.error(child.output.stderr.toString('utf8').red);
return reject(new Error(`${prog} failed with status code ${code}`));
}
resolve();
});
}));
});
which(type, prog, pify(sudoPrompt.exec)(`${prog} ${args}`, { name: 'Electron Forge' }));

export default which;

0 comments on commit 0ea55fa

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