"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const open_1 = __importDefault(require("open"));
const path_1 = require("path");
const server_1 = require("../lib/server");
async function main() {
    const path = process.argv[2];
    const execName = path_1.parse(__filename).base;
    if (!path) {
        console.error(`
Usage: yarn ts-node ${execName} <path to test run>

f.e: yarn ts-node ${execName} lib/testsResults/.root-cause/runs/mock_invocation_id/<run id>
`);
        return;
    }
    const url = await server_1.openServer(Number(process.env.PORT) || 9876, path);
    open_1.default(url);
    console.log('Press any key to exit');
    if (process.stdin.isTTY) {
        process.stdin.setRawMode(true);
    }
    process.stdin.resume();
    process.stdin.on('data', process.exit.bind(process, 0));
}
main().catch(console.error);
