Skip to content

Commit 655b0d1

Browse files
committed
refactor(installer): check that the linux installer program exists first
1 parent 2bfa373 commit 655b0d1

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/installers/linux/deb.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import pify from 'pify';
22
import sudo from 'sudo-prompt';
33

4+
import linuxInstaller from '../../util/linux-installer';
5+
46
export default async (filePath) => {
5-
await pify(sudo.exec)(`gdebi -n ${filePath}`, {
7+
linuxInstaller('Debian', 'gdebi', pify(sudo.exec)(`gdebi -n ${filePath}`, {
68
name: 'Electron Forge',
7-
});
9+
}));
810
};

src/util/linux-installer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { spawnSync } from 'child_process';
2+
3+
export default async (type, prog, promise) => {
4+
if (spawnSync('which', [prog]).status === 0) {
5+
await promise;
6+
} else {
7+
throw new Error(`${prog} is required to install ${type} packages`);
8+
}
9+
};

0 commit comments

Comments
 (0)