Object.keys(defaults).forEach(function ( mode ) { var metrics = requirem(fs.existsSync(cfgUser) ? cfgUser : cfgBase, {reload: true}); options[mode] = {}; Object.keys(metrics).forEach(function ( height ) { var conf = options[mode][height] = Object.create(defaults[mode]), vars = conf.globalVars = metrics[height]; // safe zone dimension // base dimension minus safe zone margins vars.availHeight = vars.height - vars.availTop - vars.availBottom; vars.availWidth = vars.width - vars.availLeft - vars.availRight; conf.cssFile = conf.outpath + height + '.css'; if ( conf.sourceMap ) { // more preparations conf.sourceMapFile = conf.outpath + height + '.map'; conf.sourceMapURL = height + '.map'; conf.writeSourceMap = function ( map ) { fs.writeFileSync(conf.sourceMapFile, map, {encoding:'utf8'}); gutil.log(title, '\t' + map.length + '\t' + conf.sourceMapFile.replace(/\//g, gutil.colors.grey('/'))); }; } }); });
keys.forEach(function ( height ) { var varsFileBase = process.env.STB + '/app/less/vars/' + height + '.js', varsFileUser = process.env.CWD + '/app/less/vars/' + height + '.js', vars, name; // base vars = requirem(varsFileBase, {reload: true}); // extend with less vars for ( name in vars ) { if ( vars.hasOwnProperty(name) ) { options[mode][height].globalVars[name] = vars[name]; } } // user if ( fs.existsSync(varsFileUser) ) { vars = requirem(varsFileUser, {reload: true}); // extend with less vars for ( name in vars ) { if ( vars.hasOwnProperty(name) ) { options[mode][height].globalVars[name] = vars[name]; } } } less.render(data, options[mode][height], function ( error, data ) { var file = options[mode][height].cssFile; if ( error ) { log(title, '\t0\t' + file.red + '\t(' + error.message + ' in ' + error.filename + ' ' + error.line + ':' + error.column + ')'); } else { fs.writeFileSync(file, data.css, {encoding:'utf8'}); log(title, '\t' + data.css.length + '\t' + file.replace(/\//g, '/'.grey)); } tick++; // notify gulp if ( tick === keys.length ) { done(); } }); });