<commit_before>var fs = require('fs')
  , path = require('path')
  , Builder = require('component-builder')
  , endsWith = require('./utils').endsWith
  , Batch = require('batch')
  , jade = require('jade')
  , componentStylus = require('component-stylus');

module.exports = Build;

function Build (dir) {
  var builder = this._builder = new Builder(dir);
  
  builder.use(componentStylus);
  
  if (process.env.NODE_ENV !== 'production') {
    builder.addSourceURLs();
  }
  
  builder.on('config', function () {
    builder.copyAssetsTo(builder.config.build.output);

    builder.config.paths && builder.config.paths.forEach(function (path) {
      builder.addLookup(path);
    });
  });
  
  builder.hook('before scripts', function (pkg, cb) {
    if (!pkg.config.templates) return cb();

    var jadeFiles = pkg.config.templates.filter(endsWith('jade'))
      , batch = new Batch();

    jadeFiles.forEach(function (jadeTemplate) {
      batch.push(function (done) {
        var jadeTemplatePath = pkg.path(jadeTemplate)
          , template = jade.compile(fs.readFileSync(jadeTemplatePath, 'utf-8'),{filename:jadeTemplatePath});

        pkg.addFile('scripts', jadeTemplate, "module.exports = '" + template() + "';");
        
        done();
      });
    });
    batch.end(cb);
  });
  
}

Build.prototype.build = function (done) {
  var builder = this._builder;
  
  this._builder.build(function (err, res){
    if (err) return console.log(err);
  
    var requiredLocals = '';
   
    builder.config.local && builder.config.local.forEach(function (pkg) {
      requiredLocals += 'require("' + pkg + '");\n';
    });  

    fs.writeFileSync(path.join(builder.config.build.output, builder.config.name + '.js'), res.require + res.js + "require('" + builder.config.name + "');\n" + requiredLocals);
    fs.writeFileSync(path.join(builder.config.build.output, builder.config.name + '.css'), res.css);

    done(builder.config);
  });
};
<commit_msg>Update build.js<commit_after>var fs = require('fs')
  , path = require('path')
  , Builder = require('component-builder')
  , endsWith = require('./utils').endsWith
  , Batch = require('batch')
  , jade = require('jade')
  , componentStylus = require('component-stylus');

module.exports = Build;

function Build (dir) {
  var builder = this._builder = new Builder(dir);
  
  builder.use(componentStylus);
  
  if (process.env.NODE_ENV !== 'production') {
    builder.addSourceURLs();
  }
  
  builder.on('config', function () {
    builder.copyAssetsTo(builder.config.build.output);

    builder.config.paths && builder.config.paths.forEach(function (path) {
      builder.addLookup(path);
    });
  });
  
  builder.hook('before scripts', function (pkg, cb) {
    if (!pkg.config.templates) return cb();

    var jadeFiles = pkg.config.templates.filter(endsWith('jade'))
      , batch = new Batch();

    jadeFiles.forEach(function (jadeTemplate) {
      batch.push(function (done) {
        var jadeTemplatePath = pkg.path(jadeTemplate)
          , template = jade.compile(fs.readFileSync(jadeTemplatePath, 'utf-8'),{filename:jadeTemplatePath});

        pkg.addFile('scripts', jadeTemplate, "module.exports = " + JSON.stringify(template()) + ";");
        
        done();
      });
    });
    batch.end(cb);
  });
  
}

Build.prototype.build = function (done) {
  var builder = this._builder;
  
  this._builder.build(function (err, res){
    if (err) return console.log(err);
  
    var requiredLocals = '';
   
    builder.config.local && builder.config.local.forEach(function (pkg) {
      requiredLocals += 'require("' + pkg + '");\n';
    });  

    fs.writeFileSync(path.join(builder.config.build.output, builder.config.name + '.js'), res.require + res.js + "require('" + builder.config.name + "');\n" + requiredLocals);
    fs.writeFileSync(path.join(builder.config.build.output, builder.config.name + '.css'), res.css);

    done(builder.config);
  });
};

{'fraction_non_alphanumeric': 0.172782874617737, 'fraction_numerical': 0.0005096839959225281, 'mean_word_length': 3.370824053452116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5469380', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1254, 'n_words': 209}