Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno task - Support brace expansion #91

Open
gaoxiaoliangz opened this issue Aug 30, 2023 · 5 comments
Open

deno task - Support brace expansion #91

gaoxiaoliangz opened this issue Aug 30, 2023 · 5 comments

Comments

@gaoxiaoliangz
Copy link

I have this in my deno.json

{
  "tasks": {
    "check": "deno check services/*/{prod,dev}.ts"
  }

When I run deno task check, I got:

Task check deno check services/*/{prod,dev}.ts
error: Error parsing script 'check'.

Caused by:
    Unexpected character.
      {prod,dev}.ts

My deno version:

deno 1.36.3 (release, aarch64-apple-darwin)
v8 11.6.189.12
typescript 5.1.6
@bartlomieju bartlomieju added the bug Something isn't working label Aug 30, 2023
@bartlomieju
Copy link
Member

@dsherret is this supposed to work?

@dsherret dsherret removed the bug Something isn't working label Aug 31, 2023
@dsherret dsherret changed the title Error parsing script 'check' deno task - Support brace expansion Aug 31, 2023
@dsherret
Copy link
Member

No, brace expansion has not been implemented in deno task.

@armichaud
Copy link

This is something I'd be interested in taking a crack at. Looking at the GNU docs @dsherret shared, there are a few discrete features of brace expansion we might consider implementing.

  1. Basic: Comma separate string lists, e.g. "deno check services/*/{prod,dev}.ts"
  2. Nested: "deno check services/{service1/{prod,staging,dev},service2/{prod,dev}}.ts"
  3. Numeric Range Expansion: "deno check services/service{0..10[..2]}/{prod,dev}.ts"
  4. Lexicographical Range Expansion: "deno check services/service{a..z}/{prod,dev}.ts"

Should I aim to tackle all four at once? Or should we start perhaps with just the first 1 or 2 and go from there?

@armichaud
Copy link

Having looked a bit further into this, I think this would necessitate changes to the deno_task_shell. @dsherret should we transfer this issue there?

@bartlomieju bartlomieju transferred this issue from denoland/deno Sep 1, 2023
@armichaud
Copy link

So at the very least, this would require modifying the parser such that curly braces are allowed when applying word parts combinators.

However, the major issue is that the glob module does not support string alternative syntax. A couple potential solutions to this:

  1. Use the globset crate, which supports brace expansion, instead of glob. This, however, will almost certainly behave differently: for example, it doesn't support the require-literal-leading-dot option, which is enabled here. This could be a breaking change.
  2. Write custom logic which runs at some point while we're evaluating word parts inner to replace WordParts that contain curly braces with a number of WordParts representing the expanded strings.

@dsherret between these approaches, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants