<commit_before>var fs = require('fs');
var path = require('path');
var glob = require('glob');
var exists = fs.existsSync;
var stat = fs.lstatSync;
var join = path.join;
var resolve = path.resolve;
var isWindows = process.platform === 'win32';
var splitter = isWindows ? ';' : ':';

module.exports = function(gulp) {
  var tm = new TaskManager(gulp);

  function loadTasks(moduleName) {
    tm.load(moduleName);
  }

  gulp.loadTasks = loadTasks;
  return loadTasks;
};

function TaskManager(gulp) {
  // global path
  this.globalPath = process.env['NODE_PATH'] ?
    process.env['NODE_PATH'].split(splitter) : [];
  this.tasks = [];
  this.gulp = gulp;
}

TaskManager.prototype.load = function(moduleName) {
  var gulp = this.gulp;
  this.lookup(moduleName);
  this.tasks.forEach(function(task) {
    require(task)(gulp);
  });
  this.tasks = [];
};

TaskManager.prototype.lookup = function(moduleName) {
  if (exists(moduleName)) {
    var s = stat(moduleName);

    // .loadTasks('path/to/tasks/task.js')
    if (s.isFile()) {
      this.tasks.push(moduleName);
      return;
    }

    // .loadTasks('path/to/module')
    if (s.isDirectory()) {
      this.lookupTasks(resolve(moduleName));
      this.lookupDeps(resolve(moduleName));
    }
  }

  // .loadTasks('moduleName')
  // lookup path
  // 1. global path
  // 2. node_modules path
  var paths = this.globalPath.concat(resolve('node_modules'));
  paths.forEach(function(p) {
    p = join(p, moduleName);<commit_msg>Set current working directory if moduleName doesn't exist<commit_after>var fs = require('fs');
var path = require('path');
var glob = require('glob');
var exists = fs.existsSync;
var stat = fs.lstatSync;
var join = path.join;
var resolve = path.resolve;
var isWindows = process.platform === 'win32';
var splitter = isWindows ? ';' : ':';

module.exports = function(gulp) {
  var tm = new TaskManager(gulp);

  function loadTasks(moduleName) {
    tm.load(moduleName);
  }

  gulp.loadTasks = loadTasks;
  return loadTasks;
};

function TaskManager(gulp) {
  // global path
  this.globalPath = process.env['NODE_PATH'] ?
    process.env['NODE_PATH'].split(splitter) : [];
  this.tasks = [];
  this.gulp = gulp;
}

TaskManager.prototype.load = function(moduleName) {
  var gulp = this.gulp;
  this.lookup(moduleName);
  this.tasks.forEach(function(task) {
    require(task)(gulp);
  });
  this.tasks = [];
};

TaskManager.prototype.lookup = function(moduleName) {
  // set current working directory if moduleName doesn't exist
  if (!moduleName) moduleName = process.cwd();

  if (exists(moduleName)) {
    var s = stat(moduleName);

    // .loadTasks('path/to/tasks/task.js')
    if (s.isFile()) {
      this.tasks.push(moduleName);
      return;
    }

    // .loadTasks('path/to/module')
    if (s.isDirectory()) {
      this.lookupTasks(resolve(moduleName));
      this.lookupDeps(resolve(moduleName));
    }
  }

  // .loadTasks('moduleName')
  // lookup path
  // 1. global path
  // 2. node_modules path
  var paths = this.globalPath.concat(resolve('node_modules'));
  paths.forEach(function(p) {
    p = join(p, moduleName);
{'fraction_non_alphanumeric': 0.16167471819645732, 'fraction_numerical': 0.0025764895330112722, 'mean_word_length': 3.5409356725146197, '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': '5333486', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1037, 'n_words': 204}