Skip to content

Commit

Permalink
refactor(installer): check that the linux installer program exists first
Browse files Browse the repository at this point in the history
  • Loading branch information
malept authored and MarshallOfSound committed Dec 31, 2016
1 parent fb217c7 commit fb56c54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/installers/linux/deb.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import pify from 'pify';
import sudo from 'sudo-prompt';

import linuxInstaller from '../../util/linux-installer';

export default async (filePath) => {
await pify(sudo.exec)(`gdebi -n ${filePath}`, {
linuxInstaller('Debian', 'gdebi', pify(sudo.exec)(`gdebi -n ${filePath}`, {
name: 'Electron Forge',
});
}));
};
9 changes: 9 additions & 0 deletions src/util/linux-installer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { spawnSync } from 'child_process';

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

0 comments on commit fb56c54

Please sign in to comment.