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

[FR]: Support Expanding a filegroup via a rule #790

Open
Aghassi opened this issue Mar 14, 2024 · 2 comments
Open

[FR]: Support Expanding a filegroup via a rule #790

Aghassi opened this issue Mar 14, 2024 · 2 comments
Labels
confirmation needed Waiting on confirmation of resolution from reporter before closing enhancement New feature or request

Comments

@Aghassi
Copy link
Contributor

Aghassi commented Mar 14, 2024

What is the current behavior?

There is no rule for this.

Describe the feature

I'm in the unique position where I need to expand an npm package and copy each individual file out of the package from external to another place in my WORKSPACE. If I were to use copy_to_directory, I can move the files around but I lose the granularity of each file and Bazel only sees a directory when I pass to ts_project. This means that I can't use that rule to bulk move files around.

I found this stackoverflow from a few years back that outlines a simple approach where in you can pass a filegroup to this rule and it makes an output for each file in the output group. https://stackoverflow.com/a/57983629

Having this be in bazel-lib would be fairly useful because then I can add a filegroup to the npm package which I then reference and expand anywhere. Going one step further, I expect replace_prefix or similar to exist on the rule such that I can strip out part of the source path and rewrite it for the destination path. e.g. if my source path is external/my_package/package/src I would want to rewrite it to my_package/src

@Aghassi Aghassi added the enhancement New feature or request label Mar 14, 2024
@github-actions github-actions bot added the untriaged Requires traige label Mar 14, 2024
@alexeagle
Copy link
Collaborator

I think you're just looking for https://github.com/bazelbuild/bazel-skylib/blob/main/rules/select_file.bzl ? with some list comprehension to select more than one file.

@alexeagle alexeagle added confirmation needed Waiting on confirmation of resolution from reporter before closing and removed untriaged Requires traige labels Mar 29, 2024
@Aghassi
Copy link
Contributor Author

Aghassi commented Apr 6, 2024

Maybe? Do you have an example of that doing what I described? That looks like it is just used to select files but not move them around. Maybe I'm misunderstanding the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmation needed Waiting on confirmation of resolution from reporter before closing enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants