feat: support pass all args syntax
This commit is contained in:
5
mod.ts
5
mod.ts
@@ -449,6 +449,11 @@ export function command(
|
||||
) => [key, options.default]),
|
||||
),
|
||||
})
|
||||
if (parseArgv) {
|
||||
raw = raw.replaceAll("$<*>", argv.join(" "))
|
||||
} else if (colors) {
|
||||
raw = raw.replaceAll("$<*>", italic(underline("$<*>")))
|
||||
}
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
const { alias, required, default: defaults } = args[i]
|
||||
if (parseArgv) {
|
||||
|
||||
14
mod_test.ts
14
mod_test.ts
@@ -57,6 +57,20 @@ Deno.test("deno task make: missing args required throw", async () => {
|
||||
.rejectedWith(Error, /missing argument/i)
|
||||
})
|
||||
|
||||
Deno.test("deno task make: pass all arguments", async () => {
|
||||
const stdio = [] as string[]
|
||||
const { code } = await make({
|
||||
task: "make:args_pass_all",
|
||||
argv: ["--foo", "🦕", "🦖"],
|
||||
config: "tests/deno_make.jsonc",
|
||||
log: (message) => stdio.push(message),
|
||||
stdio: "piped",
|
||||
exit: false,
|
||||
})
|
||||
expect(stdio.join("\n")).to.include("--foo").to.include("🦕").and.to.include("🦖")
|
||||
expect(code).to.equal(0)
|
||||
})
|
||||
|
||||
Deno.test("deno task make: flags", async () => {
|
||||
const stdio = [] as string[]
|
||||
const { code } = await make({
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"make:args_pass_all": {
|
||||
"task": "echo '$<*>'",
|
||||
"cwd": "tests"
|
||||
},
|
||||
"make:flags": {
|
||||
"task": "echo '$<foo> / $<bar>'",
|
||||
"cwd": "tests",
|
||||
|
||||
Reference in New Issue
Block a user