• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import minimist from "minimist";
2import os from "os";
3
4const ci = ["1", "true"].includes(process.env.CI ?? "");
5
6const parsed = minimist(process.argv.slice(2), {
7    boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci"],
8    string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
9    alias: {
10        /* eslint-disable quote-props */
11        "b": "browser",
12        "i": ["inspect", "inspect-brk", "break", "debug", "debug-brk"],
13        "t": ["tests", "test"],
14        "ru": ["runners", "runner"],
15        "r": "reporter",
16        "c": ["colors", "color"],
17        "skippercent": "skipPercent",
18        "w": "workers",
19        "f": "fix"
20        /* eslint-enable quote-props */
21    },
22    default: {
23        soft: false,
24        colors: process.env.colors || process.env.color || true,
25        debug: process.env.debug || process.env["debug-brk"] || process.env.d,
26        inspect: process.env.inspect || process.env["inspect-brk"] || process.env.i,
27        host: process.env.TYPESCRIPT_HOST || process.env.host || "node",
28        browser: process.env.browser || process.env.b || (os.platform() === "win32" ? "edge" : "chrome"),
29        timeout: process.env.timeout || 40000,
30        tests: process.env.test || process.env.tests || process.env.t,
31        runners: process.env.runners || process.env.runner || process.env.ru,
32        light: process.env.light === undefined || process.env.light !== "false",
33        reporter: process.env.reporter || process.env.r,
34        fix: process.env.fix || process.env.f,
35        workers: process.env.workerCount || ((os.cpus().length - (ci ? 0 : 1)) || 1),
36        failed: false,
37        keepFailed: false,
38        lkg: true,
39        dirty: false,
40        built: false,
41        ci,
42        bundle: true
43    }
44});
45
46/** @type {CommandLineOptions} */
47const options = /** @type {any} */ (parsed);
48
49if (options.built) {
50    options.lkg = false;
51}
52
53export default options;
54
55
56
57/**
58 * @typedef CommandLineOptions
59 * @property {boolean} dirty
60 * @property {boolean} light
61 * @property {boolean} colors
62 * @property {boolean} lkg
63 * @property {boolean} built
64 * @property {boolean} soft
65 * @property {boolean} fix
66 * @property {string} browser
67 * @property {string} tests
68 * @property {string | boolean} break
69 * @property {string | boolean} inspect
70 * @property {string} runners
71 * @property {string|number} workers
72 * @property {string} host
73 * @property {string} reporter
74 * @property {string} stackTraceLimit
75 * @property {string|number} timeout
76 * @property {boolean} failed
77 * @property {boolean} keepFailed
78 * @property {boolean} ci
79 * @property {string} shards
80 * @property {string} shardId
81 * @property {string} break
82 * @property {boolean} bundle
83 */
84void 0;
85