<commit_before>var fs    = require('fs');
var join  = require('path').join;
var spawn = require('child_process').spawn;
var shell = require('shelljs');

module.exports = function($){
  return new Electron($);
};

function Electron($){
  this.$ = $;
  this.log = require('./log')($, 'electrify:electron');
}

Electron.prototype.ensure_deps = function(done){

  this.log.info('ensuring electron dependencies');

  var node_mods = this.$.env.core.node_mods;

  var electron_dir  = join(node_mods, 'electron-prebuilt');
  var packager_dir  = join(node_mods, 'electron-packager');
  
  var electron_path = join(electron_dir, 'path.txt');
  var packager_bin  = join(node_mods, '.bin', 'electron-packager');

  if(!fs.existsSync(electron_path)){
    this.log.warn('electron-prebuilt installation seems corrupted, fixing..');
    shell.rm('-rf', electron_dir);
  } else
    this.log.info('electron-prebuilt instalation is ok, moving on');

  if(!fs.existsSync(packager_bin)){
    this.log.warn('electron=packager installation seems corrupted, fixing..');
    shell.rm('-rf', packager_dir);
  } else
    this.log.info('electron-packager instalation is ok, moving on');

  spawn(this.$.env.meteor.node, [this.$.env.meteor.npm, 'install'], {
    cwd: this.$.env.core.root,
    stdio: this.$.env.stdio
  }).on('exit', done);
};

Electron.prototype.launch = function(done) {
  this.log.info('launching electron', this.$.env.core.electron);
  this.electron_process = spawn(this.$.env.meteor.node, [
    this.$.env.core.electron,
    this.$.env.app.electrify
  ], {
    cwd: this.$.env.app.electrify,
    stdio: this.$.env.stdio,
    env: Object.create(process.env)
  });
  done();
};

Electron.prototype.terminate = function() {
  if(this.electron_process) {
    this.log.info('terminating electron');
    this.electron_process.kill();
  }
};
<commit_msg>cleaning up, improving messages<commit_after>var fs    = require('fs');
var join  = require('path').join;
var spawn = require('child_process').spawn;
var shell = require('shelljs');

module.exports = function($){
  return new Electron($);
};

function Electron($){
  this.$ = $;
  this.log = require('./log')($, 'electrify:electron');
}

Electron.prototype.ensure_deps = function(done){

  this.log.info('ensuring electron dependencies');

  var node_mods = this.$.env.core.node_mods;

  var electron_dir  = join(node_mods, 'electron-prebuilt');
  var packager_dir  = join(node_mods, 'electron-packager');
  
  var electron_path = join(electron_dir, 'path.txt');
  var packager_bin  = join(node_mods, '.bin', 'electron-packager');

  var is_broken_msg = 'installation is missing or corrupted, fixing it';
  var is_ok_msg     = 'installation seems ok, moving on';

  if(!fs.existsSync(electron_path)){
    this.log.warn('electron-prebuilt '+ is_broken_msg);
    shell.rm('-rf', electron_dir);
  } else
    this.log.info('electron-prebuilt '+ is_ok_msg);

  if(!fs.existsSync(packager_bin)){
    this.log.warn('electron-packager '+ is_broken_msg);
    shell.rm('-rf', packager_dir);
  } else
    this.log.info('electron-packager '+ is_ok_msg);

  spawn(this.$.env.meteor.node, [this.$.env.meteor.npm, 'install'], {
    cwd: this.$.env.core.root,
    stdio: this.$.env.stdio
  }).on('exit', done);
};

Electron.prototype.launch = function(done) {
  this.log.info('launching electron');
  this.electron_process = spawn(this.$.env.meteor.node, [
    this.$.env.core.electron,
    this.$.env.app.electrify
  ], {
    cwd: this.$.env.app.electrify,
    stdio: this.$.env.stdio,
    env: Object.create(process.env)
  });
  done();
};

Electron.prototype.terminate = function() {
  if(this.electron_process) {
    this.log.info('terminating electron');
    this.electron_process.kill();
  }
};

{'fraction_non_alphanumeric': 0.177938808373591, 'fraction_numerical': 0.0, 'mean_word_length': 4.070748299319728, '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': '4069169', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1287, 'n_words': 222}