<commit_before>'use strict';
const path = require('path');
const startInstance = require('./common.js').startInstance;
const createEndpoint = require('./common.js').createEndpoint;
const tmp = require('tmp');
const rmRf = require('rimraf-promise');
const mkdirp = require('mkdirp-promise/lib/node5');

class LocalRunner {
  constructor (basePath) {
    this.rootDir = tmp.dirSync({'prefix': 'arango-resilience'}).name;
    this.basePath = basePath;
  }

  createEndpoint () {
    return createEndpoint();
  }

  firstStart (instance) {
    let dir = path.join(this.rootDir, instance.name);
    let dataDir = path.join(dir, 'data');
    let appsDir = path.join(dir, 'apps');

    instance.args.unshift('--configuration=none');
    instance.args.push('--javascript.startup-directory=' + path.join(this.basePath, 'js'));
    instance.args.push('--javascript.app-path=' + appsDir);
    instance.args.push('--server.endpoint=' + instance.endpoint);
    instance.args.push(dataDir);

    let arangod = path.join(this.basePath, 'build', 'bin', 'arangod');
    if (process.env.RESILIENCE_ARANGO_WRAPPER) {
      let wrapper = process.env.RESILIENCE_ARANGO_WRAPPER.split(' ');
      instance.binary = wrapper.shift();
      instance.args = wrapper.concat(arangod, instance.args);
    } else {
      instance.binary = arangod;
    }

    return Promise.all([
      mkdirp(dataDir),
      mkdirp(appsDir)
    ])
    .then(() => {
      return startInstance(instance);
    });
  }

  restart (instance) {
    return startInstance(instance);
  }

  cleanup () {
    return rmRf(this.rootDir);
  }
}

module.exports = LocalRunner;
<commit_msg>Nuke existing instance dir before first start<commit_after>'use strict';
const path = require('path');
const startInstance = require('./common.js').startInstance;
const createEndpoint = require('./common.js').createEndpoint;
const tmp = require('tmp');
const rmRf = require('rimraf-promise');
const mkdirp = require('mkdirp-promise/lib/node5');

class LocalRunner {
  constructor (basePath) {
    this.rootDir = tmp.dirSync({'prefix': 'arango-resilience'}).name;
    this.basePath = basePath;
  }

  createEndpoint () {
    return createEndpoint();
  }

  firstStart (instance) {
    let dir = path.join(this.rootDir, instance.name);
    let dataDir = path.join(dir, 'data');
    let appsDir = path.join(dir, 'apps');

    instance.args.unshift('--configuration=none');
    instance.args.push('--javascript.startup-directory=' + path.join(this.basePath, 'js'));
    instance.args.push('--javascript.app-path=' + appsDir);
    instance.args.push('--server.endpoint=' + instance.endpoint);
    instance.args.push(dataDir);

    let arangod = path.join(this.basePath, 'build', 'bin', 'arangod');
    if (process.env.RESILIENCE_ARANGO_WRAPPER) {
      let wrapper = process.env.RESILIENCE_ARANGO_WRAPPER.split(' ');
      instance.binary = wrapper.shift();
      instance.args = wrapper.concat(arangod, instance.args);
    } else {
      instance.binary = arangod;
    }

    return rmRf(dir)
    .then(() => Promise.all([
      mkdirp(dataDir),
      mkdirp(appsDir)
    ]))
    .then(() => {
      return startInstance(instance);
    });
  }

  restart (instance) {
    return startInstance(instance);
  }

  cleanup () {
    return rmRf(this.rootDir);
  }
}

module.exports = LocalRunner;

{'fraction_non_alphanumeric': 0.16189327705758216, 'fraction_numerical': 0.0006029544769369913, 'mean_word_length': 3.6019417475728157, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '6560757', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1063, 'n_words': 188}