Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
fix(*): add module
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Dec 7, 2015
1 parent 4046658 commit e9e3410
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
35 changes: 35 additions & 0 deletions engines/enb-bem-grid/techs/.enb/make.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var path = require('path'),
techs = {
levels : require('enb-bem-techs/techs/levels'),
provide : require('enb/techs/file-provider'),
deps : require('enb-bem-techs/techs/deps-old'),
files : require('enb-bem-techs/techs/files'),
postcss : require('enb-postcss/techs/enb-postcss')
};

module.exports = function(grid, browsers) {
return function(config) {
config.node('build/', function(nodeConfig) {
nodeConfig.addTechs([
[techs.levels, {
levels : [
{ path : '../../../common.blocks' }
]
}],
[techs.provide, { target : '?.bemdecl.js' }],
[techs.deps],
[techs.files],
[techs.postcss, {
plugins : require('../../../../.enb/postcss-plugins')({
grid : grid,
browsers : browsers
})
}]
]);

nodeConfig.addTargets([
'?.css'
]);
});
};
};
8 changes: 8 additions & 0 deletions engines/enb-bem-grid/techs/build/build.bemdecl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
exports.blocks = [
{
"name" : "mq"
},
{
"name" : "row"
}
];
34 changes: 34 additions & 0 deletions engines/enb-bem-grid/techs/enb-bem-grid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var vowFs = require('enb/lib/fs/async-fs'),
make = require('enb/lib/api/make'),
path = require('path'),
exec = require('child_process').exec;

module.exports = require('enb/lib/build-flow').create()
.name('enb-bem-grid')
.target('target', '?.css')
.defineOption('config')
.defineOption('browsers')
.defineOption('source')
.useSourceText('source', '?')
.builder(function(preTargetSource) {
var _this = this,
prefixedConfig = {};
Object.keys(_this._config).forEach(function(key) {
prefixedConfig['grid' + capitalize(key)] = _this._config[key];
});

return make([], {
dir : __dirname,
config : require('./.enb/make.js')(prefixedConfig, this._browsers)
}).then(function() {
return vowFs.read(path.join(__dirname, 'build', 'build.css'), 'utf8')
.then(function(gridRes) {
return gridRes + preTargetSource;
});
});
})
.createTech();

function capitalize(s) {
return s[0].toUpperCase() + s.slice(1);
}

0 comments on commit e9e3410

Please sign in to comment.