Skip to content

Commit

Permalink
refactor(installer): replace electron-sudo with sudo-prompt
Browse files Browse the repository at this point in the history
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 29, 2017
1 parent 33532f7 commit 0ea55fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -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",
Expand Down
19 changes: 3 additions & 16 deletions src/util/linux-installer.js
@@ -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) {
Expand All @@ -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.