Skip to content

feat: add parse_task_dependency for deno task dependency args#183

Closed
bartlomieju wants to merge 1 commit into
mainfrom
feat/task-dependency-args
Closed

feat: add parse_task_dependency for deno task dependency args#183
bartlomieju wants to merge 1 commit into
mainfrom
feat/task-dependency-args

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Adds a parse_task_dependency helper (and a TaskDependency type) that
splits a deno task dependency entry into a task name and the literal
arguments to forward to that task. This is the deno_task_shell piece of
denoland/deno#27870, which asks for dependencies like
"test --coverage='.coverage/' --clean" so a task can run a dependency
with extra flags without defining a duplicate task.

Today dependencies are treated as bare task names, so the argument
splitting has to live somewhere. Doing it here lets the deno CLI reuse
the existing shell parser instead of hand-rolling quote handling: the
helper parses the entry, requires it to be a single plain command, and
returns the first word as the name and the remaining words as args, with
quotes honored and removed (so --flag='a b' becomes the single argument
--flag=a b).

To keep a dependency string unambiguous at configuration-load time,
anything that would need a runtime environment or change control flow is
rejected with a descriptive error: pipelines, boolean and sequential
operators (&&, ||, ;), background &, redirects, subshells, !
negation, environment variable assignments, and any argument containing
variable substitution, command substitution, tilde expansion, or brace
expansion. Bare names like "test" keep working unchanged.

This only adds the parsing helper; wiring it into the task graph
(notably keying the dependency graph on name plus args so the same task
can run with different arguments) is a follow-up in the deno repo.

Unit tests cover the accepted forms, quote handling, and each rejected
case.

Add a `parse_task_dependency` helper (and `TaskDependency` type) that
splits a dependency entry such as `test --coverage='.coverage/' --clean`
into a task name and the literal arguments to forward to it, honoring and
removing quotes.

It reuses the existing shell parser and rejects anything that would
require a runtime environment or alter control flow (pipelines, boolean
and sequential operators, background `&`, redirects, subshells, `!`
negation, env assignments, and args containing variable/command/tilde/
brace expansions), so a dependency string resolves unambiguously at
configuration-load time.

Groundwork for denoland/deno#27870.
Comment thread src/parser.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should live in deno instead? It doesn't really have to do with shell parsing or execution.

@bartlomieju

Copy link
Copy Markdown
Member Author

Agreed with @dsherret — this is consumer-side policy over the already-public parser AST (deno-specific TaskDependency type and error messages, no new shell parsing/execution), so it belongs in the deno repo's deno task code rather than here. It can call deno_task_shell::parser::parse() and do the same AST walk without any new API surface in this library. Closing; will move the logic into denoland/deno as part of denoland/deno#27870.

@bartlomieju bartlomieju closed this Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants