<commit_before>import fileSystem from "fs-extra";
import temp from "temp";
import path from "path";
import rimraf from "rimraf";

import ChainLink from "mrt";
import {
		execSync as runCommandSync
} from "child_process";

const setParameters = Symbol(),
			setDefaultPaths = Symbol();

export default class StimpakSandbox extends ChainLink {
	initialize() {
		//temp.track();

		this[setParameters]();
		this[setDefaultPaths]();

		this.configure();
	}

	configure() { /* STUB */ }

	setup() {
		this.makeDirectories();
		this.copyFiles();
		this.symlinkFiles();
	}

	cleanup() {
		this.unSymlinkFiles();
		temp.cleanupSync();
	}

	runWithArguments(argumentString) {
		const paths = this.paths();
		const stdout = runCommandSync(`node ${paths.bin} ${argumentString}`, { cwd: paths.root });
		return stdout.toString();
	}

	makeDirectories() {
		this.makeDirectory().forEach(directoryPath => {
			fileSystem.mkdirsSync(directoryPath);
		});
	}

	copyFiles() {
		this.copy().forEach(copyPath => {
			const copyFromPath = copyPath[0];
			const copyToPath = copyPath[1];
			fileSystem.copySync(copyFromPath, copyToPath);
		});
	}

	symlinkFiles() {
		this.symlink().forEach(symlinkPath => {
			const symlinkFromPath = symlinkPath[0];
			const symlinkToPath = symlinkPath[1];
			fileSystem.symlinkSync(symlinkFromPath, symlinkToPath);
		});
	}

	unSymlinkFiles() {
		this.symlink().forEach(symlinkPath => {
			const symlinkToPath = symlinkPath[1];

			rimraf.sync(symlinkToPath);
		});
	}

	[setParameters]() {
		this.parameters("paths").mergeKeyValues;
		this.parameters(
			"copy",
			"symlink"
		).aggregate.multiValue;

		this.parameters(
			"makeDirectory"
		).aggregate;
	}

	[setDefaultPaths]() {
		const defaultPaths = {};

		defaultPaths.root = temp.mkdirSync();

		defaultPaths.projectDirectory =
			path.normalize(`${__dirname}/../../../..`);

		defaultPaths.bin =
			`${defaultPaths.projectDirectory}/es5/lib/cli/stimpak.cli.js`;

		defaultPaths.sourceDirectory =
			`${defaultPaths.projectDirectory}/source`;

		defaultPaths.fixtureDirectory =
			`${defaultPaths.sourceDirectory}/spec/cli/fixtures`;

		defaultPaths.fixtures = {
			error:
				`${defaultPaths.fixtureDirectory}/stimpak-generator-error`,
			generator:
				`${defaultPaths.fixtureDirectory}/stimpak-generator`
		};

		defaultPaths.globalNodeModulesDirectory =
			runCommandSync(
				"npm config get prefix",
				{ cwd: defaultPaths.root }
			).toString().replace(/[\n\r]/, "/lib/node_modules");

		this.paths(defaultPaths);
	}
}<commit_msg>added debugging to sandboxed tests for travis ci<commit_after>import fileSystem from "fs-extra";
import temp from "temp";
import path from "path";
import rimraf from "rimraf";
import ChainLink from "mrt";

import {
		execSync as runCommandSync
} from "child_process";

const setParameters = Symbol(),
			setDefaultPaths = Symbol();

export default class StimpakSandbox extends ChainLink {
	initialize() {
		//temp.track();

		this[setParameters]();
		this[setDefaultPaths]();

		this.configure();

		this.showDebug = true;

		if (this.showDebug) {
			console.log("StimpakSandbox DEBUG:");
		}
	}

	configure() { /* STUB */ }

	setup() {
		this.makeDirectories();
		this.copyFiles();
		this.symlinkFiles();
	}

	cleanup() {
		this.unSymlinkFiles();
		temp.cleanupSync();
	}

	runWithArguments(argumentString) {
		const paths = this.paths();
		const stdout = runCommandSync(`node ${paths.bin} ${argumentString}`, { cwd: paths.root });
		return stdout.toString();
	}

	makeDirectories() {
		this.debug("makeDirectories");
		this.makeDirectory().forEach(directoryPath => {
			this.debug(`\t${directoryPath}`);
			fileSystem.mkdirsSync(directoryPath);
		});
	}

	copyFiles() {
		this.debug("copyFiles");
		this.copy().forEach(copyPath => {
			const copyFromPath = copyPath[0];
			const copyToPath = copyPath[1];
			this.debug(`\tFrom: ${copyFromPath}`);
			this.debug(`\tTo: ${copyToPath}`);
			this.debug("");
			fileSystem.copySync(copyFromPath, copyToPath);
		});
	}

	symlinkFiles() {
		this.debug("symlinkFiles");
		this.symlink().forEach(symlinkPath => {
			const symlinkFromPath = symlinkPath[0];
			const symlinkToPath = symlinkPath[1];
			this.debug(`\tFrom: ${symlinkFromPath}`);
			this.debug(`\tTo: ${symlinkToPath}`);
			this.debug("");
			fileSystem.symlinkSync(symlinkFromPath, symlinkToPath);
		});
	}

	unSymlinkFiles() {
		this.symlink().forEach(symlinkPath => {
			const symlinkToPath = symlinkPath[1];

			rimraf.sync(symlinkToPath);
		});
	}

	[setParameters]() {
		this.parameters("paths").mergeKeyValues;
		this.parameters(
			"copy",
			"symlink"
		).aggregate.multiValue;

		this.parameters(
			"makeDirectory"
		).aggregate;
	}

	[setDefaultPaths]() {
		const defaultPaths = {};

		defaultPaths.root = temp.mkdirSync();

		defaultPaths.projectDirectory =
			path.normalize(`${__dirname}/../../../..`);

		defaultPaths.bin =
			`${defaultPaths.projectDirectory}/es5/lib/cli/stimpak.cli.js`;

		defaultPaths.sourceDirectory =
			`${defaultPaths.projectDirectory}/source`;

		defaultPaths.fixtureDirectory =
			`${defaultPaths.sourceDirectory}/spec/cli/fixtures`;

		defaultPaths.fixtures = {
			error:
				`${defaultPaths.fixtureDirectory}/stimpak-generator-error`,
			generator:
				`${defaultPaths.fixtureDirectory}/stimpak-generator`
		};

		defaultPaths.globalNodeModulesDirectory =
			runCommandSync(
				"npm config get prefix",
				{ cwd: defaultPaths.root }
			).toString().replace(/[\n\r]/, "/lib/node_modules");

		this.paths(defaultPaths);
	}

	debug(message) {
		if (this.showDebug) {
			console.log(`\t${message}`);
		}
	}
}
{'fraction_non_alphanumeric': 0.16056034482758622, 'fraction_numerical': 0.0021551724137931034, 'mean_word_length': 4.243879472693032, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5385287', 'n_tokens_mistral': 2099, 'n_tokens_neox': 1856, 'n_words': 293}