Skip to content

Commit 1e453cc

Browse files
authored
fix: better handling of job positional arg (#1299)
1 parent 9277472 commit 1e453cc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/index.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@ process.on("SIGUSR2", async () => await cleanupJobResources(jobs));
5050
}
5151
},
5252
builder: (y: any) => {
53-
return y.positional("job", {
54-
describe: "Jobname's to execute",
55-
type: "array",
56-
});
53+
return y
54+
.positional("job", {
55+
describe: "Jobname's to execute",
56+
type: "string", // Type here is referring to each element of the positional args
57+
})
58+
// by default yargs's positional options (args) can be used as options (flags) so this coerce is solely for
59+
// handling scenario when a single --job option flag is passed
60+
// Once https://github.com/yargs/yargs/issues/2196 is implemented, we can probably remove this
61+
.coerce("job", (args: string[]) => {
62+
if (!Array.isArray(args)) return [args];
63+
return args;
64+
});
5765
},
5866
command: "$0 [job..]",
5967
describe: "Runs the entire pipeline or job's",

0 commit comments

Comments
 (0)