-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dmitry Akimov
committed
Mar 25, 2018
1 parent
83bfbdf
commit 9e33dc2
Showing
5 changed files
with
35 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
'use strict'; | ||
|
||
var prepareEntityData = require('./prepare-entity-data'), | ||
createEntity = require('./create-entity'), | ||
template = require('./template'); | ||
const getEntityData = require('./get-entity-data'); | ||
const getPath = require('./get-path'); | ||
const template = require('./template'); | ||
const createEntity = require('./create-entity'); | ||
|
||
module.exports = function create(entities, levels, techs, options) { | ||
var createRes = prepareEntityData(entities, levels, techs, options); | ||
var entityData = getEntityData(entities, levels, techs, options); | ||
|
||
return Promise.all(createRes.map(item => | ||
template.apply(item).then(tmpl => createEntity(item.path, tmpl, item.levelOptions)) | ||
)); | ||
return Promise.all(entityData.map(item => | ||
template.apply(item) | ||
.then(content => | ||
createEntity(getPath(item), content, item.levelOptions) | ||
) | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require('path'); | ||
const scheme = require('@bem/fs-scheme'); | ||
const BemCell = require('@bem/cell'); | ||
|
||
module.exports = function getPath(item) { | ||
const levelOptions = item.config.levelSync(item.level) || {}; | ||
const levelScheme = levelOptions.scheme; | ||
const buildPath = scheme(levelScheme).path; | ||
const pathToFile = buildPath( | ||
new BemCell({ entity: item.entity, tech: item.tech }), | ||
item.levelOptions.schemeOptions || item.levelOptions | ||
); | ||
const absolutePath = path.join(path.resolve(item.level), pathToFile); | ||
|
||
return absolutePath; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters