-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
41 lines (36 loc) · 1.55 KB
/
index.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
var path = require('path'),
cpy = require('cpy'),
del = require('del'),
bemConfig = require('bem-config')(),
config = bemConfig.moduleSync('bem-lib-site'),
prepareData = require('./lib/prepare-data'),
processDocs = require('./lib/process-docs'),
processBlocks = require('./lib/process-blocks'),
fsHelpers = require('./lib/fs-helpers'),
bundleName = 'index',
pathToBundle = path.resolve(__dirname, 'desktop.bundles', bundleName),
BEMTREE = require(path.join(pathToBundle, bundleName + '.bemtree')).BEMTREE,
BEMHTML = require(path.join(pathToBundle, bundleName + '.bemhtml')).BEMHTML;
module.exports = function(pathToData) {
if (!pathToData) {
throw new Error('Please provide path to library data');
}
var data = prepareData(pathToData, config),
outputFolder = data.outputFolder;
return del(outputFolder, { force: true }).then(function() {
return Promise.all(data.langs.reduce(function(promises, lang) {
var folder = path.join(outputFolder, lang);
return promises.concat(
fsHelpers.touch(path.join(folder, '.nojekyll')),
cpy([
path.join(__dirname, 'desktop.bundles', 'index', 'index.{css,js}'),
path.join(__dirname, 'favicon.ico'),
path.join(pathToData, 'favicon.ico')
], folder),
processDocs(data, lang, BEMTREE, BEMHTML),
processBlocks(data, lang, BEMTREE, BEMHTML)
);
}, []))
})
.catch(console.error);
};