-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
31 lines (26 loc) · 926 Bytes
/
cli.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
const fs = require('fs');
const path = require('path');
const util = require('util');
const bemToolsConfig = require('.');
const writeFile = util.promisify(fs.writeFile);
const mkdir = util.promisify(fs.mkdir);
const CONFIG_DIR = '.bem-config';
function noOp() {}
module.exports = function() {
this
.title('Works with bem-config').helpful()
.act(function(opts, args) {
return Promise.all([
bemToolsConfig(),
mkdir(CONFIG_DIR).catch(err => {
if (err.code !== 'EEXIST') throw err;
})
]).then(([confData]) => {
return [
writeFile(path.join(CONFIG_DIR, 'index.json'), JSON.stringify(confData.all)),
writeFile(path.join(CONFIG_DIR, 'levels.json'), JSON.stringify(confData.levels)),
];
}).then(noOp);
})
.end();
};