setup(tx): add support for passing flags down to commands

This commit is contained in:
Abdullah Atta
2025-10-08 10:55:52 +05:00
parent 39079612aa
commit b3e34d68e1

View File

@@ -25,7 +25,7 @@ import { fileURLToPath } from "url";
import { performance } from "perf_hooks"; import { performance } from "perf_hooks";
import { createHash } from "crypto"; import { createHash } from "crypto";
const args = { _: [], exclude: [] }; const args = { _: [], exclude: [], force: false, verbose: false, all: false };
const shortFlags = { f: "force", v: "verbose", a: "all", e: "exclude" }; const shortFlags = { f: "force", v: "verbose", a: "all", e: "exclude" };
const arrayFlags = { exclude: true }; const arrayFlags = { exclude: true };
for (let i = 2; i < process.argv.length; i++) { for (let i = 2; i < process.argv.length; i++) {
@@ -39,7 +39,8 @@ for (let i = 2; i < process.argv.length; i++) {
args[flag] = value args[flag] = value
? value.split(",") ? value.split(",")
: process.argv[++i]?.split(",") || []; : process.argv[++i]?.split(",") || [];
else if (flag) args[flag] = true; else if (flag && !!args[flag]) args[flag] = true;
else args._.push(arg);
} }
} }
@@ -362,5 +363,8 @@ if (args.all) {
await writeFile(tmp, JSON.stringify(cache)); await writeFile(tmp, JSON.stringify(cache));
await rename(tmp, cachePath); await rename(tmp, cachePath);
console.timeEnd("Ready in"); console.timeEnd("Ready in");
await runScript(cmd, pkg.path, { verbose: true, args: args._.slice(1) }); await runScript(cmd, pkg.path, {
verbose: true,
args: ["--", ...args._.slice(1)]
});
} }