Hey guys when I use nx…

1 minute read

Hey guys, when I use nx run-many can I target projects by tag? e.g. nx run-many --target=lint --tags=type:ui and nx would lint all libs with tag type:ui ?


As far as I’ve seen in the source code no. I’ve written a small script that wraps the nx run many command and reads the nx.json and get the projects out of the labes then passing the projects to the nx run many

/** Filter incoming projects based on the tag defined in the options. */ function filterTaggedProjects( nxJson: NxJson, buildTag: string, selfProject: string, ): string[] { return ( Object.entries(nxJson.projects) // filter out the starter project (self) .filter(([project]) => project !== selfProject) // filter in all projects that include the selected tag .filter(([_project, { tags }]) => tags?.includes(buildTag)) .map(([project]) => project) ); }

you cann pass the projects as comma seperated list to the run many with --projects

if you add the script to the npm package you can leverage it via yarn run-many --tag=my-tag and it is running under the hood the nx one

Ok cool, it still feels like it should be an nx internal feature though

you are completely right :smile:

a query language like bazel provides it would be nice to query projects depending on different constraints

something like that: