bazelbuild/bazel-gazelle

extra_args lost when running in a sub-directory

Globegitter opened this issue · 2 comments

I have written a plugin for nodejs and to be able to configure the name of the external repository where all yarn/npm dependencies are being installed added a flag npm_workspace_name which I am setting as follows:

gazelle(
    name = "gazelle",
    gazelle = ":gazelle_js",
    prefix = "github.com/ecosia/core",
    extra_args = [
        "-npm_workspace_name",
        "global-yarn",
    ],
)

This works fine when running bazel run //:gazelle but if I no run bazel run //:gazelle -- app to just run gazelle in a subdir the flag is being lost and the default value of that flag is being applied which is quite confusing.

Maybe it makes sense to not strip off extra_args when running in a subdir?

I don't think we can change this behavior. Subcommands like update-repos take options that may be completely different than what fix or update accept.

The documentation isn't really clear on what this attribute does though. That should be fixed.

Stumbled on this.

This command works for subdirectory

bazel run //:gazelle --   -npm_workspace_name global-yarn  app