2022-10-07 19:50:46 +03:00
|
|
|
import minimist from "minimist";
|
|
|
|
import os from "os";
|
2018-06-19 08:45:13 +03:00
|
|
|
|
2022-10-07 19:50:46 +03:00
|
|
|
const ci = ["1", "true"].includes(process.env.CI ?? "");
|
2022-09-07 02:36:37 +03:00
|
|
|
|
2022-10-07 19:50:46 +03:00
|
|
|
const parsed = minimist(process.argv.slice(2), {
|
2023-06-02 23:00:47 +03:00
|
|
|
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle", "typecheck", "lint", "coverage"],
|
2021-02-13 03:01:22 +03:00
|
|
|
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
|
2018-06-19 08:45:13 +03:00
|
|
|
alias: {
|
|
|
|
b: "browser",
|
2021-02-13 03:01:22 +03:00
|
|
|
i: ["inspect", "inspect-brk", "break", "debug", "debug-brk"],
|
2020-01-03 00:28:44 +03:00
|
|
|
t: ["tests", "test"],
|
|
|
|
ru: ["runners", "runner"],
|
2018-06-19 08:45:13 +03:00
|
|
|
r: "reporter",
|
2020-01-03 00:28:44 +03:00
|
|
|
c: ["colors", "color"],
|
2019-08-16 20:41:11 +03:00
|
|
|
skippercent: "skipPercent",
|
2018-06-19 08:45:13 +03:00
|
|
|
w: "workers",
|
2019-01-28 08:56:56 +03:00
|
|
|
f: "fix",
|
2018-06-19 08:45:13 +03:00
|
|
|
},
|
|
|
|
default: {
|
|
|
|
soft: false,
|
|
|
|
colors: process.env.colors || process.env.color || true,
|
|
|
|
debug: process.env.debug || process.env["debug-brk"] || process.env.d,
|
|
|
|
inspect: process.env.inspect || process.env["inspect-brk"] || process.env.i,
|
|
|
|
host: process.env.TYPESCRIPT_HOST || process.env.host || "node",
|
|
|
|
browser: process.env.browser || process.env.b || (os.platform() === "win32" ? "edge" : "chrome"),
|
2023-01-24 00:49:26 +03:00
|
|
|
timeout: +(process.env.timeout ?? 0) || 40000,
|
2018-06-19 08:45:13 +03:00
|
|
|
tests: process.env.test || process.env.tests || process.env.t,
|
|
|
|
runners: process.env.runners || process.env.runner || process.env.ru,
|
|
|
|
light: process.env.light === undefined || process.env.light !== "false",
|
|
|
|
reporter: process.env.reporter || process.env.r,
|
|
|
|
fix: process.env.fix || process.env.f,
|
2023-01-24 00:49:26 +03:00
|
|
|
workers: +(process.env.workerCount ?? 0) || ((os.cpus().length - (ci ? 0 : 1)) || 1),
|
2018-06-25 21:26:08 +03:00
|
|
|
failed: false,
|
2018-07-10 22:00:30 +03:00
|
|
|
keepFailed: false,
|
2023-03-08 02:34:47 +03:00
|
|
|
lkg: false,
|
2019-01-28 08:56:56 +03:00
|
|
|
dirty: false,
|
2022-09-07 02:36:37 +03:00
|
|
|
built: false,
|
|
|
|
ci,
|
2022-11-09 02:39:04 +03:00
|
|
|
bundle: true,
|
|
|
|
typecheck: true,
|
2023-02-27 22:06:20 +03:00
|
|
|
lint: true,
|
2023-06-02 23:00:47 +03:00
|
|
|
coverage: false,
|
2018-06-19 08:45:13 +03:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-10-07 19:50:46 +03:00
|
|
|
/** @type {CommandLineOptions} */
|
|
|
|
const options = /** @type {any} */ (parsed);
|
|
|
|
|
2023-03-08 02:34:47 +03:00
|
|
|
if (options.built && options.lkg) {
|
|
|
|
throw new Error("--built and --lkg are mutually exclusive");
|
2019-01-28 08:56:56 +03:00
|
|
|
}
|
|
|
|
|
2022-11-17 23:44:39 +03:00
|
|
|
if (!options.bundle && !options.typecheck) {
|
|
|
|
throw new Error("--no-typecheck cannot be passed when bundling is disabled");
|
|
|
|
}
|
|
|
|
|
2022-10-07 19:50:46 +03:00
|
|
|
export default options;
|
|
|
|
|
2018-06-19 08:45:13 +03:00
|
|
|
/**
|
2022-10-07 19:50:46 +03:00
|
|
|
* @typedef CommandLineOptions
|
2018-07-10 22:00:30 +03:00
|
|
|
* @property {boolean} dirty
|
2018-06-19 08:45:13 +03:00
|
|
|
* @property {boolean} light
|
|
|
|
* @property {boolean} colors
|
2018-07-10 22:00:30 +03:00
|
|
|
* @property {boolean} lkg
|
2019-01-28 08:56:56 +03:00
|
|
|
* @property {boolean} built
|
2018-06-19 08:45:13 +03:00
|
|
|
* @property {boolean} soft
|
|
|
|
* @property {boolean} fix
|
|
|
|
* @property {string} browser
|
|
|
|
* @property {string} tests
|
2024-06-26 19:41:01 +03:00
|
|
|
* @property {boolean} skipSysTests
|
2022-10-07 19:50:46 +03:00
|
|
|
* @property {string | boolean} break
|
2021-02-13 03:01:22 +03:00
|
|
|
* @property {string | boolean} inspect
|
2018-06-19 08:45:13 +03:00
|
|
|
* @property {string} runners
|
2023-01-24 00:49:26 +03:00
|
|
|
* @property {number} workers
|
2018-06-19 08:45:13 +03:00
|
|
|
* @property {string} host
|
|
|
|
* @property {string} reporter
|
|
|
|
* @property {string} stackTraceLimit
|
2023-01-24 00:49:26 +03:00
|
|
|
* @property {number} timeout
|
2018-06-25 21:26:08 +03:00
|
|
|
* @property {boolean} failed
|
|
|
|
* @property {boolean} keepFailed
|
2022-09-07 02:36:37 +03:00
|
|
|
* @property {boolean} ci
|
2022-10-07 19:50:46 +03:00
|
|
|
* @property {string} shards
|
|
|
|
* @property {string} shardId
|
2022-09-14 02:21:03 +03:00
|
|
|
* @property {string} break
|
|
|
|
* @property {boolean} bundle
|
2022-11-09 02:39:04 +03:00
|
|
|
* @property {boolean} typecheck
|
2023-02-27 22:06:20 +03:00
|
|
|
* @property {boolean} lint
|
2023-06-02 23:00:47 +03:00
|
|
|
* @property {boolean} coverage
|
2018-06-19 08:45:13 +03:00
|
|
|
*/
|
2019-06-20 00:12:17 +03:00
|
|
|
void 0;
|