Code coverage report for lib/util/templateStream.js

Statements: 100% (16 / 16)      Branches: 100% (2 / 2)      Functions: 100% (4 / 4)      Lines: 100% (15 / 15)      Ignored: none     

All files » lib/util/ » templateStream.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27    1 1 1 1   1   1 5     5 5   5 282 282   1455   5 5      
'use strict';
 
var fs = require('fs');
var through = require('through2');
var handlebars = require('handlebars');
var extend = require('extend');
 
var blacklisted = ['app', 'index'];
 
module.exports = function (options) {
  var things = extend(options, {
    modules: [],
  });
  var template = fs.readFileSync(options.templatePath, { encoding: 'utf8' });
  var compiled = handlebars.compile(template);
 
  return through.obj(function (chunk, _, next) {
    things.modules.push(chunk);
    next();
  }, function (next) {
    things.modules.sort(function(a, b) {return a.name < b.name ? -1 : 1;});
 
    this.push(compiled(things));
    next();
  });
};