<commit_before>'use strict';

var childProcess = require('child_process');
var fs = require('fs-extra');
var path = require('path');
var shelljs = require('shelljs');

var util = require('./util.js');

var TEMP = path.join(process.cwd(), 'node_modules', '.npm-install-version-temp');

function install(npmPackage) {
  var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  var _options$destination = options.destination;
  var destination = _options$destination === undefined ? util.sanitize(npmPackage) : _options$destination;
  var _options$overwrite = options.overwrite;
  var overwrite = _options$overwrite === undefined ? false : _options$overwrite;


  if (!npmPackage) util.error();
  var destinationPath = path.join('node_modules', destination);
  if (!overwrite && util.directoryExists(destinationPath)) {
    return console.log('Module at ' + destinationPath + ' already exists, skipping');
  }

  var errored = false;
  try {
    (function () {
      // make temp install dir
      shelljs.rm('-rf', TEMP);
      shelljs.mkdir('-p', path.join(TEMP, 'node_modules'));

      // install package to temp dir
      var installOptions = {
        cwd: TEMP,
        stdio: [null, null, null]
      };
      childProcess.spawnSync('npm', ['install', npmPackage], installOptions);

      // get real package name
      var packageName = util.getPackageName(npmPackage);

      // copy deps
      shelljs.mkdir(path.join(TEMP, 'node_modules', packageName, 'node_modules'));
      shelljs.ls(path.join(TEMP, 'node_modules')).forEach(function (dep) {
        if (dep === packageName) return;
        var from = path.join(TEMP, 'node_modules', dep).toString();
        var to = path.join(TEMP, 'node_modules', packageName, 'node_modules', dep).toString();
        shelljs.mv(from, to);
      });

      // copy to node_modules/
      shelljs.rm('-rf', destinationPath);
      shelljs.mv(path.join(TEMP, 'node_modules', packageName), destinationPath);

      console.log('Installed ' + npmPackage + ' to ' + destinationPath);
    })();
  } catch (err) {
    errored = true;
    console.log('Error installing ' + npmPackage);
    console.log(err.toString());
  } finally {
    // clean up temp install dir
    shelljs.rm('-rf', TEMP);

    if (errored) process.exit(1);
  }
}
<commit_msg>Build<commit_after>'use strict';

var childProcess = require('child_process');
var fs = require('fs-extra');
var path = require('path');
var shelljs = require('shelljs');

var util = require('./util.js');

var TEMP = path.join(process.cwd(), 'node_modules', '.npm-install-version-temp');

function install(npmPackage) {
  var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  var _options$destination = options.destination;
  var destination = _options$destination === undefined ? util.sanitize(npmPackage) : _options$destination;
  var _options$overwrite = options.overwrite;
  var overwrite = _options$overwrite === undefined ? false : _options$overwrite;


  if (!npmPackage) util.error();
  var destinationPath = path.join(process.cwd(), 'node_modules', destination);
  if (!overwrite && util.directoryExists(destinationPath)) {
    return console.log('Directory at ' + destinationPath + ' already exists, skipping');
  }

  var errored = false;
  try {
    (function () {
      // make temp install dir
      shelljs.rm('-rf', TEMP);
      shelljs.mkdir('-p', path.join(TEMP, 'node_modules'));

      // install package to temp dir
      var installOptions = {
        cwd: TEMP,
        stdio: [null, null, null]
      };
      childProcess.spawnSync('npm', ['install', npmPackage], installOptions);

      // get real package name
      var packageName = util.getPackageName(npmPackage);

      // move deps inside package
      shelljs.mkdir(path.join(TEMP, 'node_modules', packageName, 'node_modules'));
      shelljs.ls(path.join(TEMP, 'node_modules')).forEach(function (dep) {
        if (dep === packageName) return;
        var from = path.join(TEMP, 'node_modules', dep).toString();
        var to = path.join(TEMP, 'node_modules', packageName, 'node_modules', dep).toString();
        shelljs.mv(from, to);
      });

      // copy to node_modules/
      shelljs.rm('-rf', destinationPath);
      shelljs.mv(path.join(TEMP, 'node_modules', packageName), destinationPath);

      console.log('Installed ' + npmPackage + ' to ' + destinationPath);
    })();
  } catch (err) {
    errored = true;
    console.log('Error installing ' + npmPackage);
    console.log(err.toString());
  } finally {
    // clean up temp install dir
    shelljs.rm('-rf', TEMP);

    if (errored) process.exit(1);
  }
}

{'fraction_non_alphanumeric': 0.1547695605573419, 'fraction_numerical': 0.0017148981779206859, 'mean_word_length': 3.4995178399228544, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7007310', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1392, 'n_words': 329}