<commit_before>import * as path from "path";
import { spawn } from "child_process";
import { logger } from "../logger";

module.exports = function (env: EnvironmentVariables, config: IM2MConfig, port: number, skipWebDriverUpdate: boolean, specs?: string) {
    return (skipWebDriverUpdate ? Promise.resolve(0) : webDriverUpdate()).then((exitCode) => {
        if (exitCode === 0) {
            let specPaths = path.join(config.e2eDir, "**", "*.e2e.ts");
            if (specs) {
                specPaths = specs.split(",").map(spec => path.resolve(path.join(__dirname, "..", "config"), path.join(config.rootDir, spec))).join(",");
            }
            return runProtractor(port, specPaths);
        } else {
            return exitCode;
        }
    });
};

function getProtractorDir() {
    let result = require.resolve("protractor");
    if (result) {
        // result is now something like
        // c:\\Source\\gulp-protractor\\node_modules\\protractor\\lib\\protractor.js
        return path.resolve(path.join(path.dirname(result), "..", "..", ".bin"));
    }
    throw new Error("No protractor installation found.");
}

function getProtractorBinaryPath(binaryName) {
    const winExt = /^win/.test(process.platform) ? ".cmd" : "";
    return path.join(getProtractorDir(), binaryName + winExt);
}

function webDriverUpdate(): Promise<number> {
    return new Promise((resolve) => {
        const wdProcess = spawn(getProtractorBinaryPath("webdriver-manager"), ["update"], { stdio: "inherit" });
        wdProcess.on("close", (exitCode) => {
            resolve(exitCode);
        });
    });
}

function runProtractor(port: number, specs: string) {
    return new Promise((resolve) => {
        const configPath = path.resolve("/", path.join(__dirname, "config", "protractor.conf.js"));
        logger.debug(`Running the following command: protractor ${configPath} --port ${port} --specs ${specs}`);
        const protractorProcess = spawn(getProtractorBinaryPath("protractor"), [configPath, "--port", String(port), "--specs", specs], { stdio: "inherit" });
        protractorProcess.on("close", (exitCode) => {
            resolve(exitCode);
        });
    });
}<commit_msg>fix(e2e): use correct path for protractor.config.js<commit_after>import * as path from "path";
import { spawn } from "child_process";
import { logger } from "../logger";

module.exports = function (env: EnvironmentVariables, config: IM2MConfig, port: number, skipWebDriverUpdate: boolean, specs?: string) {
    return (skipWebDriverUpdate ? Promise.resolve(0) : webDriverUpdate()).then((exitCode) => {
        if (exitCode === 0) {
            let specPaths = path.join(config.e2eDir, "**", "*.e2e.ts");
            if (specs) {
                specPaths = specs.split(",").map(spec => path.resolve(path.join(__dirname, "..", "config"), path.join(config.rootDir, spec))).join(",");
            }
            return runProtractor(port, specPaths);
        } else {
            return exitCode;
        }
    });
};

function getProtractorDir() {
    let result = require.resolve("protractor");
    if (result) {
        // result is now something like
        // c:\\Source\\gulp-protractor\\node_modules\\protractor\\lib\\protractor.js
        return path.resolve(path.join(path.dirname(result), "..", "..", ".bin"));
    }
    throw new Error("No protractor installation found.");
}

function getProtractorBinaryPath(binaryName) {
    const winExt = /^win/.test(process.platform) ? ".cmd" : "";
    return path.join(getProtractorDir(), binaryName + winExt);
}

function webDriverUpdate(): Promise<number> {
    return new Promise((resolve) => {
        const wdProcess = spawn(getProtractorBinaryPath("webdriver-manager"), ["update"], { stdio: "inherit" });
        wdProcess.on("close", (exitCode) => {
            resolve(exitCode);
        });
    });
}

function runProtractor(port: number, specs: string) {
    return new Promise((resolve) => {
        const configPath = path.resolve("/", path.join(__dirname, "..", "config", "protractor.conf.js"));
        logger.debug(`Running the following command: protractor ${configPath} --port ${port} --specs ${specs}`);
        const protractorProcess = spawn(getProtractorBinaryPath("protractor"), [configPath, "--port", String(port), "--specs", specs], { stdio: "inherit" });
        protractorProcess.on("close", (exitCode) => {
            resolve(exitCode);
        });
    });
}
{'fraction_non_alphanumeric': 0.17269439421338156, 'fraction_numerical': 0.0024864376130198916, 'mean_word_length': 3.116279069767442, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '6680240', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1266, 'n_words': 273}