<commit_before>/**
 * @example <caption>When escape pressed. Abort launch.</caption>
 * expandPath(undefined); // => undefined

 * @example <caption>Absolute path, on linux and darwin</caption>
 * expandPath("/home/wsh/proj0/path/to/script.sh");
 * // => "/home/wsh/proj0/path/to/script.sh"
 * @example <caption>Using {workspaceFolder}, on linux and darwin</caption>
 * expandPath("{workspaceFolder}/path/to/script.sh");
 * // => "/home/wsh/proj0/path/to/script.sh"

 * @example <caption>Absolute path, on windows</caption>
 * expandPath("C:\\Users\\wsh\\proj0\\path\\to\\script.sh");
 * // => "/mnt/c/Users/wsh/proj0/path/to/script.sh"
 * @example <caption>Using {workspaceFolder}, on windows</caption>
 * expandPath("{workspaceFolder}\\path\\to\\script.sh");
 * // => "/mnt/c/Users/wsh/proj0/path/to/script.sh"
 */
export function expandPath(path?: string, rootPath?: string): string | undefined {

	if (!path) {
		return undefined;
	};

	if (rootPath) {
		path = path.replace("{workspaceFolder}", <string>rootPath);
	}

	if (process.platform === "win32" && !path.startsWith("/")) {
		path = "/mnt/" + path.substr(0, 1).toLowerCase() + path.substr("X:".length).split("\\").join("/");
	}

	return path;
}<commit_msg>Remove OS dependency from expandPath<commit_after>/**
 * @example <caption>When escape pressed. Abort launch.</caption>
 * // can't execute jsdoctest
 * // expandPath(undefined, "C:\\Users\\wsh\proj0"); // => undefined
 *
 * @example <caption>Absolute path</caption>
 * expandPath("C:\\Users\\wsh\\proj0\\path\\to\\script.sh", "C:\\Users\\wsh\proj0");
 * // => "/mnt/c/Users/wsh/proj0/path/to/script.sh"
 *
 * @example <caption>Using {workspaceFolder}, on windows</caption>
 * expandPath("{workspaceFolder}\\path\\to\\script.sh", "C:\\Users\\wsh\\proj0");
 * // => "/mnt/c/Users/wsh/proj0/path/to/script.sh"
 *
 * @example <caption>If path starts with "/", no WSL path conversion</caption>
 * expandPath("/mnt/c/Users/wsh/proj0/path/to/script.sh", "C:\\Users\\wsh\\proj0");
 * // => "/mnt/c/Users/wsh/proj0/path/to/script.sh"
 */
export function expandPath(path?: string, rootPath?: string): string | undefined {

	if (!path) {
		return undefined;
	};

	if (rootPath) {
		path = path.replace("{workspaceFolder}", <string>rootPath);
	}

	if (!path.startsWith("/")) {
		path = "/mnt/" + path.substr(0, 1).toLowerCase() + path.substr("X:".length).split("\\").join("/");
	}

	return path;
}
{'fraction_non_alphanumeric': 0.22846441947565543, 'fraction_numerical': 0.008739076154806492, 'mean_word_length': 3.866396761133603, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 32, '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': '5585903', 'n_tokens_mistral': 880, 'n_tokens_neox': 847, 'n_words': 138}