Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Add support for @bem/cell #11

Merged
merged 4 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lib/schemes/flat.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
var bemNaming = require('bem-naming');
var path = require('path'),
BemCell = require('@bem/cell'),
bemNaming = require('bem-naming');

module.exports = {
path: function(entity, tech, options) {
options || (options = {});

var layer = '';
var _tech = tech;

if (BemCell.isBemCell(entity)) {
entity.layer && (layer = entity.layer);
if (typeof tech === 'object') {
options = tech;
}
_tech = entity.tech;
entity = entity.entity;
}

var naming = bemNaming(options.naming);

return naming.stringify(entity) + '.' + tech;
return path.join(layer,
naming.stringify(entity) + (_tech ? '.' + _tech : ''));
}
};
30 changes: 23 additions & 7 deletions lib/schemes/nested.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
var path = require('path'),
BemCell = require('@bem/cell'),
bemNaming = require('bem-naming');

module.exports = {
path: function(entity, tech, options) {
options || (options = {});
var naming = bemNaming(options.naming),
elemFolder = naming.elemDelim + entity.elem,
modFolder = naming.modDelim + entity.modName,
folder = path.join(entity.block,
entity.elem ? elemFolder : '',
entity.modName ? modFolder : '');

var layer = '';
var modName = '';
var _tech = tech;

if (BemCell.isBemCell(entity)) {
entity.layer && (layer = entity.layer);
if (typeof tech === 'object') {
options = tech;
}
_tech = entity.tech;
entity = entity.entity;
modName = Object(entity.mod).name;
} else {
modName = entity.modName;
}

var naming = bemNaming(options.naming);
var folder = path.join(layer, entity.block,
entity.elem ? (naming.elemDelim + entity.elem) : '',
modName ? (naming.modDelim + modName) : '');

return path.join(folder,
naming.stringify(entity) + '.' + tech);
naming.stringify(entity) + (_tech ? '.' + _tech : ''));
}
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
},
"homepage": "https://github.com/bem-sdk/bem-fs-scheme#readme",
"dependencies": {
"@bem/cell": "^0.2.1",
"bem-naming": "^1.0.1"
},
"devDependencies": {
"@bem/entity-name": "^1.1.0",
"chai": "^3.5.0",
"eslint": "^3.1.1",
"eslint-config-pedant": "^0.7.0",
Expand Down
Loading