<commit_before>#!/usr/bin/env node

'use strict';

/**
 * Borrowed from gulp
 * The MIT License (MIT)
 * Copyright (c) 2014-2015 Fractal <<EMAIL>>
 */

var fs = require('fs');
var path = require('path');
var archy = require('archy');
var chalk = require('chalk');
var tildify = require('tildify');
var gutil = require('gulp-util');
var Liftoff = require('liftoff');
var v8flags = require('v8flags');
var resolve = require('resolve');
var prettyTime = require('pretty-hrtime');
var argv = require('minimist')(process.argv.slice(2));

var verb = require('verb');
verb.extend('argv', argv);
verb.emit('init');

if (!argv._.length && argv.no) {
  exit(0);
}

/**
 * Local dependencies
 */

var completion = require('../lib/completion');
var taskTree = require('../lib/task-tree');
var pkg = require('../package');


// store a reference to the current CWD
process.env.INIT_CWD = process.cwd();

var cli = new Liftoff({
  name: 'verb',
  completions: completion,
  extensions: { '.js': null, '.coffee': 'coffee-script/register' },
  nodeFlags: v8flags
});

// exit with 0 or 1
var failed = false;
process.once('exit', function(code) {
  if (code === 0 && failed) {
    exit(1);
  }
});

/**
 * flags
 */

var versionFlag = argv.v || argv.version;
var tasksFlag = argv.T || argv.tasks;
var tasks = argv._;
var toRun = tasks.length ? tasks : ['default'];

var simpleTasksFlag = argv['tasks-simple'];
var shouldLog = !argv.silent && !simpleTasksFlag;

if (!shouldLog) {
  gutil.log = function(){};
}

cli.on('require', function(name) {
  gutil.log('Requiring external module', chalk.magenta(name));
});

cli.on('requireFail', function(name) {
  gutil.log(chalk.red('Failed to load external module'), chalk.magenta(name));
});

cli.on('respawn', function (flags, child) {
  var nodeFlags = chalk.magenta(flags.join(', '));
  var pid = chalk.magenta(child.pid);
  gutil.log('Node flags detected:', nodeFlags);
  gutil.log('Respawned to PID:', pid);
});

cli.launch({
  cwd: argv.cwd,
  configPath: argv.verbfile,
  require: argv.require,
  completion: argv.completion
}, run);


// the actual logic
function run(env) {
  console.log(); // empty line
  var verbfile = env.configPath;

  if (versionFlag && tasks.length === 0) {
    gutil.log('CLI version', pkg.version);
    if (env.modulePackage && typeof env.modulePackage.version !== 'undefined') {
      gutil.log('Local version', env.modulePackage.version);
    }
  }

  // `node_modules/verb`
  if (!verbfile || !env.modulePath || !fs.existsSync(env.modulePath)) {
    env.modulePath = resolve.sync('verb');
  }

  // chdir before requiring `verbfile.js` to allow users to chdir as needed
  if (process.cwd() !== env.cwd) {
    process.chdir(env.cwd);
    gutil.log('working directory changed to', tildify(env.cwd));
  }

  // `verbfile.js`
  if (!verbfile) {
    verbfile = resolve.sync('verb-default');
    env.configBase = path.dirname(env.configBase);
    verb.emit('pre-load');
    require(verbfile)(verb);
  } else {
    // this is what actually loads up the verbfile
    verb.emit('pre-load');
    require(verbfile);
  }

  gutil.log('using verbfile', tildify(verbfile));

  // require verb
  var verbInst = require(env.modulePath);
  logEvents(verbInst);<commit_msg>remove temporary code<commit_after>#!/usr/bin/env node

'use strict';

/**
 * Borrowed from gulp
 * The MIT License (MIT)
 * Copyright (c) 2014-2015 Fractal <<EMAIL>>
 */

var fs = require('fs');
var path = require('path');
var archy = require('archy');
var chalk = require('chalk');
var tildify = require('tildify');
var gutil = require('gulp-util');
var Liftoff = require('liftoff');
var v8flags = require('v8flags');
var resolve = require('resolve');
var prettyTime = require('pretty-hrtime');
var argv = require('minimist')(process.argv.slice(2));

/**
 * Local dependencies
 */

var completion = require('../lib/completion');
var taskTree = require('../lib/task-tree');
var pkg = require('../package');

// store a reference to the current CWD
process.env.INIT_CWD = process.cwd();

var cli = new Liftoff({
  name: 'verb',
  completions: completion,
  extensions: { '.js': null, '.coffee': 'coffee-script/register' },
  v8flags: v8flags
});

// exit with 0 or 1
var failed = false;
process.once('exit', function(code) {
  if (code === 0 && failed) {
    exit(1);
  }
});

/**
 * flags
 */

var versionFlag = argv.v || argv.version;
var tasksFlag = argv.T || argv.tasks;
var tasks = argv._;
var toRun = tasks.length ? tasks : ['default'];

var simpleTasksFlag = argv['tasks-simple'];
var shouldLog = !argv.silent && !simpleTasksFlag;

if (!shouldLog) {
  gutil.log = function(){};
}

cli.on('require', function(name) {
  gutil.log('Requiring external module', chalk.magenta(name));
});

cli.on('requireFail', function(name) {
  gutil.log(chalk.red('Failed to load external module'), chalk.magenta(name));
});

cli.on('respawn', function (flags, child) {
  var nodeFlags = chalk.magenta(flags.join(', '));
  var pid = chalk.magenta(child.pid);
  gutil.log('Node flags detected:', nodeFlags);
  gutil.log('Respawned to PID:', pid);
});

cli.launch({
  cwd: argv.cwd,
  configPath: argv.verbfile,
  require: argv.require,
  completion: argv.completion
}, run);


// the actual logic
function run(env) {
  console.log(); // empty line
  var verbfile = env.configPath;

  if (versionFlag && tasks.length === 0) {
    gutil.log('CLI version', pkg.version);
    if (env.modulePackage && typeof env.modulePackage.version !== 'undefined') {
      gutil.log('Local version', env.modulePackage.version);
    }
  }

  // `node_modules/verb`
  if (!verbfile || !env.modulePath || !fs.existsSync(env.modulePath)) {
    /* deps: verb */
    env.modulePath = resolve.sync('verb');
  }

  // chdir before requiring `verbfile.js` to allow users to chdir as needed
  if (process.cwd() !== env.cwd) {
    process.chdir(env.cwd);
    gutil.log('working directory changed to', tildify(env.cwd));
  }

  // require verb
  var verbInst = require(env.modulePath);
  verbInst.extend('argv', argv);
  verbInst.emit('init');

  if (!argv._.length && argv.no) {
    exit(0);
  }

  // `verbfile.js`
  if (!verbfile) {
    verbfile = resolve.sync('verb-default');
    env.configBase = path.dirname(env.configBase);
    verbInst.emit('pre-load');
    require(verbfile)(verbInst);
  } else {
    // this is what actually loads up the verbfile
    verbInst.emit('pre-load');
    require(verbfile);
  }

  gutil.log('using verbfile', tildify(verbfile));

  logEvents(verbInst);
{'fraction_non_alphanumeric': 0.18079183420971234, 'fraction_numerical': 0.005722239406124343, 'mean_word_length': 3.914133738601824, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5538762', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2198, 'n_words': 522}