turborepo

Is there a way to invert a filter in Turbo?


I want to use Turbo's include filtering to filter out a workspace that has a slow set of unit tests.

I already saw TurboRepo, run only some workspaces, and the above documentation, so I know that I can filter the build to a specific workspace like so:

turbo build --filter=@acme/web

But is it possible to negate a filter, so that a specific workspace is excluded?

That is: if I have three workspaces, foo, bar, baz, how can I run only foo and bar without having to specify them individually?

This question is close, but to run 14 of my 15 workspaces I'd have to list all 14 of them (and if a new workspace is added I'd have to add it to the filter). This is an undesirable amount of work, I would prefer to negate the single workspace that I don't want to run. If that's possible.


Solution

  • Documentation:

    • !: Negate targets from the selection.
    • ... using packages: Select all packages in the Package Graph relative to the target. Using ... before the package name will select dependents of the target while using ... after the package name will select dependencies of the target. ... using Git commits: Select a range using []...[].
    • ^: Omit the target from the selection when using ....

    Example:

    # Any packages in `apps` subdirectories except ./apps/admin
    turbo run build --filter=./apps/* --filter=!./apps/admin
    

    If you want to filter by workspace name:

    turbo run test  --filter=!'<workspace name here>'
    

    (the single quotes were necessary for me due to zsh)