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

Provide a way to unregister watcher #28

Open
gajus opened this issue Mar 21, 2023 · 0 comments
Open

Provide a way to unregister watcher #28

gajus opened this issue Mar 21, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@gajus
Copy link
Owner

gajus commented Mar 21, 2023

Not sure if necessary, but there are cases when we want to run a particular trigger only once.

Consider how to combine watch mode with manual task execution: There are steps in our setup that need to run once, but then may need to be re-run during the lifetime of the watch mode, e.g. We have a script to download assets from Figma. It makes no sense to re-run this logic based on local file changes, but need to provide a way for users to re-run this script when they need to. In our case, we run it once when initiating Turbowatch and then anyone can run it manually by using turbo generate, which will be picked up by Turbowarch. For Turborepo, this probably means that watch scripts just utilize dependsOn to run some tasks once before going into the watch mode.

As far as I can think, this is true only for commands that need to once at the start. We are currently handling this with:

{
  expression: ['match', '*'],
  interruptible: false,
  name: 'generate',
  onChange: async ({ spawn, first }) => {
    if (first) {
      await spawn`pnpm turbo run generate`;
    }
  },
},

This works, but it will keep logging generate every time it detects relevant changes. A more elegant solution would allow trigger to deregister or simply indicate that trigger only has to run once at the start.

@gajus gajus added the enhancement New feature or request label Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant