From 01d2a38824c85c2144a3794393dee0ae53b17956 Mon Sep 17 00:00:00 2001 From: Simon Lecoq <22963968+lowlighter@users.noreply.github.com> Date: Wed, 8 Nov 2023 05:51:34 +0000 Subject: [PATCH] feat: support pass all args syntax --- mod.ts | 5 +++++ mod_test.ts | 14 ++++++++++++++ tests/deno_make.jsonc | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/mod.ts b/mod.ts index 84d8f40..d257d31 100644 --- a/mod.ts +++ b/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) { diff --git a/mod_test.ts b/mod_test.ts index ea29923..d589488 100644 --- a/mod_test.ts +++ b/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({ diff --git a/tests/deno_make.jsonc b/tests/deno_make.jsonc index 220490f..beb1909 100644 --- a/tests/deno_make.jsonc +++ b/tests/deno_make.jsonc @@ -37,6 +37,10 @@ } ] }, + "make:args_pass_all": { + "task": "echo '$<*>'", + "cwd": "tests" + }, "make:flags": { "task": "echo '$ / $'", "cwd": "tests",