<commit_before>'use strict';
var mockBin = require('mock-bin');
var which = require('shelljs').which;

var rescapeChars = /\\/g;

module.exports = function (js, command) {
	var originalGit = which('git').stdout.replace(rescapeChars, '\\\\');

	if (command) {
		js = 'var argv = process.argv;' +
			'var commandExists = false;' +
			'var length = argv.length;' +
			'while (--length) {' +
				'if (argv[length] === "' + command + '") {' +
					'commandExists = true;' +
					'break;' +
				'}' +
			'}' +
			'if (commandExists) {' +
				js +
			'} else {' +
				'var childProcess = require("child_process");' +
				'argv.shift();' +
				'argv.shift();' +
				'childProcess.spawn("' + originalGit + '", argv, {' +
					'stdio: "inherit"' +
				'});' +
			'}';
	}

	return mockBin('git', 'node', js);<commit_msg>rescapeChars => rbackslash<commit_after>'use strict';
var mockBin = require('mock-bin');
var which = require('shelljs').which;

var rbackslash = /\\/g;

module.exports = function (js, command) {
	var originalGit = which('git').stdout.replace(rbackslash, '\\\\');

	if (command) {
		js = 'var argv = process.argv;' +
			'var commandExists = false;' +
			'var length = argv.length;' +
			'while (--length) {' +
				'if (argv[length] === "' + command + '") {' +
					'commandExists = true;' +
					'break;' +
				'}' +
			'}' +
			'if (commandExists) {' +
				js +
			'} else {' +
				'var childProcess = require("child_process");' +
				'argv.shift();' +
				'argv.shift();' +
				'childProcess.spawn("' + originalGit + '", argv, {' +
					'stdio: "inherit"' +
				'});' +
			'}';
	}

	return mockBin('git', 'node', js);
{'fraction_non_alphanumeric': 0.23110018438844498, 'fraction_numerical': 0.0, 'mean_word_length': 2.9610705596107056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5839309', 'n_tokens_mistral': 698, 'n_tokens_neox': 579, 'n_words': 112}