<commit_before>'use strict';

import fs from 'fs';
import path from 'path';

const exists = fs.existsSync;

function isObject (obj) {
  return ( typeof obj === 'object' && !Array.isArray(obj) );
}

// Deep assign
function assign (target, source) {
  if (isObject(target) && isObject(source)) {
    Object.keys(source).reduce((target, key) => {
      if (!target.hasOwnProperty(key)) {
        target[key] = source[key];
      }
      else {
        target[key] = isObject(source[key]) ? assign(target[key], source[key]) : source[key];
      }
      return target;
    }, target);
  }

  return target;
}

function getPackageJson(d) {
  console.log(d);
  var p = path.join(d, 'package.json')
  return exists(p) ? require(p) : false
}

function getRoot () {
  let pkgJson = false;

  if (!!~__dirname.indexOf('node_modules')) {
    let dir = module.id;

    while (path.basename(dir) !== 'node_modules') {
      dir = path.dirname(dir);
    }
    return [ path.dirname(dir), pkgJson ];
  }

  let dir = module;

  while (dir.parent && !pkgJson) {
    dir = dir.parent;
    pkgJson = getPackageJson(path.dirname(dir.filename));
  }
  return [ path.dirname(dir.filename), pkgJson ];
}

function getBaseInfo () {
  const [ rootPath, pkgJson ] = getRoot();

  return [
    process.env.NODE_ENV || 'development',
    rootPath,<commit_msg>remove console.log<commit_after>'use strict';

import fs from 'fs';
import path from 'path';

const exists = fs.existsSync;

function isObject (obj) {
  return ( typeof obj === 'object' && !Array.isArray(obj) );
}

// Deep assign
function assign (target, source) {
  if (isObject(target) && isObject(source)) {
    Object.keys(source).reduce((target, key) => {
      if (!target.hasOwnProperty(key)) {
        target[key] = source[key];
      }
      else {
        target[key] = isObject(source[key]) ? assign(target[key], source[key]) : source[key];
      }
      return target;
    }, target);
  }

  return target;
}

function getPackageJson(dir) {
  var pkg = path.join(dir, 'package.json')
  return exists(pkg) ? require(pkg) : false
}

function getRoot () {
  let pkgJson = false;

  if (!!~__dirname.indexOf('node_modules')) {
    let dir = module.id;

    while (path.basename(dir) !== 'node_modules') {
      dir = path.dirname(dir);
    }
    return [ path.dirname(dir), pkgJson ];
  }

  let dir = module;

  while (dir.parent && !pkgJson) {
    dir = dir.parent;
    pkgJson = getPackageJson(path.dirname(dir.filename));
  }
  return [ path.dirname(dir.filename), pkgJson ];
}

function getBaseInfo () {
  const [ rootPath, pkgJson ] = getRoot();

  return [
    process.env.NODE_ENV || 'development',
    rootPath,
{'fraction_non_alphanumeric': 0.16209101165851825, 'fraction_numerical': 0.0, 'mean_word_length': 3.2289348171701113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1591078', 'n_tokens_mistral': 907, 'n_tokens_neox': 887, 'n_words': 197}