setup: add support for passing args down to command

This commit is contained in:
Abdullah Atta
2025-10-08 10:28:02 +05:00
parent 8dcff49797
commit be1af3111f

View File

@@ -55,8 +55,8 @@ const rootPkg = readJson(path.join(root, "package.json"));
const config = rootPkg.taskRunner || { projects: ["packages/*"], tasks: [] }; const config = rootPkg.taskRunner || { projects: ["packages/*"], tasks: [] };
const cachePath = path.join(root, ".taskcache"); const cachePath = path.join(root, ".taskcache");
const [project, ...taskParts] = args.all const [project, ...taskParts] = args.all
? [null, ...args._.at(-1).split(":")] ? [null, ...args._[0].split(":")]
: args._.at(-1).split(":"); : args._[0].split(":");
const cmd = taskParts.join(":"); const cmd = taskParts.join(":");
const pkgCache = new Map(); const pkgCache = new Map();
const depMemo = new Map(); const depMemo = new Map();
@@ -166,7 +166,7 @@ async function runScript(command, pkg, opts) {
try { try {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
const verbose = opts.verbose || isVerbose; const verbose = opts.verbose || isVerbose;
const child = spawn("npm", ["run", command], { const child = spawn("npm", ["run", command, ...(opts.args || [])], {
cwd: pkg, cwd: pkg,
stdio: verbose ? "inherit" : "pipe", stdio: verbose ? "inherit" : "pipe",
shell: true shell: true
@@ -362,5 +362,5 @@ 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 }); await runScript(cmd, pkg.path, { verbose: true, args: args._.slice(1) });
} }