forked from ottomatica/slim
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdependencies.js
42 lines (34 loc) · 1.02 KB
/
dependencies.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const hasbin = require('hasbin');
const providers = Object.keys(require('./providers'));
const { error } = require('./logger');
const depMap = {
'build': [
() => mustBin('cpio'),
() => mustBin('docker'),
() => mustBin('gzip'),
() => mustBin('mkisofs'),
],
'delete': [],
'images': [],
'run': [],
'vms': []
}
const mustBin = bin => {
if (!hasbin.sync(bin)) throw `You must have ${bin} installed to build a microkernel`;
}
exports.check = argv => {
let cmd = argv._[0];
try {
if (providers.length === 0) {
throw 'You don\'t have any providers installed! Please see the docs for a list of supported providers';
}
let { provider } = argv;
if (provider && providers.indexOf(provider) === -1) {
throw `Provider ${provider} is not installed! Please see the docs for a list of supported providers`;
}
depMap[cmd].forEach(d => d(argv));
} catch (e) {
error(e);
process.exit(1);
}
};