<commit_before>require('coffee-script');

var path = require('path'),
    fs = require('fs'),
    util = require('util'),
    shell = require('shelljs'),
    EventEmitter = require('events').EventEmitter,
    adapters = require('./adapters'),
    compress = require('./utils/compressor'),
    output_path = require('./utils/output_path'),
    Helper = require('./utils/compile_helper'),
    file_helper = require('./utils/file_helper');

function Compiler(){ EventEmitter.call(this); }
util.inherits(Compiler, EventEmitter);
module.exports = Compiler;

Compiler.prototype.finish = function(){
  this.emit('finished');
};

Compiler.prototype.compile = function(file, cb){
  var adapters = get_adapters_by_extension(file.split('.').slice(1));
  var self = this;
  var fh = file_helper(file);

  adapters.forEach(function(adapter, i){
    console.log('compiling ' + adapter.settings.file_type);

    var intermediate = adapters.length - i - 1 > 0 ? true : false;

    // file should be written here, not in the compiler
    // this way it can also handle layouts

    adapter.compile(fh, function(err, compiled){
      if (err) { return self.emit('error', err); }

      if (intermediate) {
        // pass through to the next compiler
        console.log('passing '.yellow + adapter.settings.file_type.yellow + ' through'.yellow);
        fh.contents = compiled;
      } else {
        // write the file (and layout in the future)
        fh.write(compiled);
      }

      cb();
    });

  });

};

Compiler.prototype.copy = function(file, cb){
  // TODO: Run the file copy operations as async (ncp)
  var destination = output_path(file);
  var extname = path.extname(file).slice(1);
  var types = ['html', 'css', 'js'];

  if (types.indexOf(extname) > 0) {
    var write_content = fs.readFileSync(file, 'utf8');

    if (global.options.compress) {
      write_content = compress(write_content, extname);
    }

    fs.writeFileSync(destination, write_content);
  } else {
    shell.cp('-f', file, destination);
  }<commit_msg>remove console.logs, general cleaning<commit_after>require('coffee-script');

var path = require('path'),
    fs = require('fs'),
    util = require('util'),
    shell = require('shelljs'),
    EventEmitter = require('events').EventEmitter,
    adapters = require('./adapters'),
    compress = require('./utils/compressor'),
    output_path = require('./utils/output_path'),
    Helper = require('./utils/compile_helper'),
    file_helper = require('./utils/file_helper');

function Compiler(){ EventEmitter.call(this); }
util.inherits(Compiler, EventEmitter);
module.exports = Compiler;

Compiler.prototype.finish = function(){
  this.emit('finished');
};

Compiler.prototype.compile = function(file, cb){
  var adapters = get_adapters_by_extension(file.split('.').slice(1));
  var fh = file_helper(file);
  var self = this;

  adapters.forEach(function(adapter, i){
    var intermediate = adapters.length - i - 1 > 0 ? true : false;

    adapter.compile(fh, function(err, compiled){
      if (err) { return self.emit('error', err); }
      intermediate ? fh.contents = compiled : fh.write(compiled)
      cb();
    });

  });

};

Compiler.prototype.copy = function(file, cb){
  // TODO: Run the file copy operations as async (ncp)
  var destination = output_path(file);
  var extname = path.extname(file).slice(1);
  var types = ['html', 'css', 'js'];

  if (types.indexOf(extname) > 0) {
    var write_content = fs.readFileSync(file, 'utf8');

    if (global.options.compress) {
      write_content = compress(write_content, extname);
    }

    fs.writeFileSync(destination, write_content);
  } else {
    shell.cp('-f', file, destination);
  }
{'fraction_non_alphanumeric': 0.1580952380952381, 'fraction_numerical': 0.0032653061224489797, 'mean_word_length': 3.589263420724095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2705935', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1113, 'n_words': 257}