Skip to content
This repository has been archived by the owner on Jan 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #322 from bem/bem-create-techs
Browse files Browse the repository at this point in the history
bem create: Allow techs specifying using dot notation
  • Loading branch information
arikon committed Nov 30, 2012
2 parents 8a1917a + 0716c2e commit 875cfbd
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions lib/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ module.exports = function() {
}
}

// Try to get techs specified using dot notation
if (partial.tech) {
partial.techs = partial.tech.split(',');
delete partial.tech;
}

prev = bemUtil.extend(item, partial);
if (!prev.block) return;

Expand All @@ -114,16 +120,27 @@ module.exports = function() {

techs = context.getDefaultTechs();

if (!techs.length) return Q.reject('You should specify techs to create using --force-tech, -T or --add-tech, -t options');

opts.block && opts.block.forEach(eachBlock);
args.entities && args.entities.forEach(eachEntity);

return Q.all(items.map(function(item) {
return Q.all(techs.map(function(t) {
return context.getTech(t).createByDecl(item, opts.level, addOpts);
})).get(0);
})).get(0);

var t = [].concat(techs).concat(item.techs || []);

if (!t.length) {
return Q.reject(['Can\'t create BEM entity: ', bemUtil.bemKey(item), '\n',
'You should specify techs to create using --force-tech, -T ',
'or --add-tech, -t options or using dot notaion, ',
'e.g. block.css'].join(''));
}

return Q.all(t.map(function(t) {
return context.getTech(t).createByDecl(item, opts.level, addOpts);
}))
.get(0);

}))
.get(0);

});

Expand Down

0 comments on commit 875cfbd

Please sign in to comment.