This repository was archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall.js
More file actions
46 lines (42 loc) · 1.54 KB
/
install.js
File metadata and controls
46 lines (42 loc) · 1.54 KB
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
43
44
45
46
'use strict';
const ora = require('ora');
const installPlugin = require('../install-plugin');
const installStarterkit = require('../install-starterkit');
const resolveConfig = require('../resolve-config');
const wrapAsync = require('../utils').wrapAsync;
const writeJsonAsync = require('../utils').writeJsonAsync;
/**
* install
* @desc Handles async install and activation of starterkits/plugins
* @param {object} options
*/
const install = options => wrapAsync(function*() {
const config = yield resolveConfig(options.parent.config);
const spinner = ora(`⊙ patternlab → Installing additional resources …`).start();
if (options.starterkits && Array.isArray(options.starterkits)) {
const starterkits = yield Promise.all(options.starterkits.map(starterkit =>
wrapAsync(function*() {
spinner.text = `⊙ patternlab → Installing starterkit: ${starterkit}`;
return yield installStarterkit({
name: starterkit,
value: starterkit
}, config)
})
));
spinner.succeed(`⊙ patternlab → Installed following starterkits: ${starterkits.join(', ')}`);
}
if (options.plugins && Array.isArray(options.plugins)) {
const plugins = yield Promise.all(options.plugins.map(plugin =>
wrapAsync(function*() {
return yield installPlugin({
name: plugin,
value: plugin
}, config)
})
));
spinner.succeed(`⊙ patternlab → Installed following plugins: ${plugins.join(', ')}`);
}
yield writeJsonAsync(options.parent.config, config);
spinner.succeed(`⊙ patternlab → Updated config`);
});
module.exports = install;