Visitar URL original
Support file globs with `--watch-path` · Issue #45182 · nodejs/node · GitHub
The Wayback Machine - https://web.archive.org/web/20240411063025/https://github.com/nodejs/node/issues/45182
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

Support file globs with --watch-path #45182

Open
ghost opened this issue Oct 25, 2022 · 9 comments
Open

Support file globs with --watch-path #45182

ghost opened this issue Oct 25, 2022 · 9 comments
Labels
feature request Issues that request new features to be added to Node.js. watch-mode Issues and PRs related to watch mode

Comments

@ghost
Copy link

ghost commented Oct 25, 2022

What is the problem this feature will solve?

The new experimental watch feature is awesome, but sometimes apps depend on non-imported files or data. For example, if your app has a set of templates that are read/cached at server start, updating an HTML file won't restart the process.

What is the feature you are proposing to solve the problem?

It would be extremely useful to provide an optional list of file globs that would also trigger a process restart. For example:

# current
$ node --watch app.mjs

# proposed
$ node --watch app.mjs views/*.html

Note: this syntax is just to illustrate the idea.

What alternatives have you considered?

Some template engines/libraries have caching logic built in so it's disabled during local development, but supporting this in a more generic way would open up a lot of additional use cases without having to explicitly code against NODE_ENV or enabling/disabling caching. Since the watch feature already seems to do exactly what would be needed to make this work, it would simply have to accept an optional glob or list of globs to also watch along with any imports.

@ghost ghost added the feature request Issues that request new features to be added to Node.js. label Oct 25, 2022
@MoLow MoLow added the watch-mode Issues and PRs related to watch mode label Oct 26, 2022
@MoLow
Copy link
Member

MoLow commented Oct 26, 2022

I would say there are two separate issues raised here:

  1. watching paths/files that are not required, which is currently supported with --watch-path
  2. using globs as an input for this flag - there have been a few discussions about adding glob support to node and I hope that will eventually happen allowing this to work, but it is currently out of the scope of watch mode.

@ghost
Copy link
Author

ghost commented Oct 26, 2022 •

Ah, wow, I don't know how I missed --watch-path when it's literally right below --watch in the docs, haha. The globs would definitely be a nice to have, but --watch-path does pretty much what I needed, so appreciate the reply!

EDIT: On a side note, the docs state This option is only supported on macOS and Windows., but it appears to work just fine on linux (Ubuntu).

@MoLow MoLow closed this as completed Oct 26, 2022
@karlhorky
Copy link

karlhorky commented Oct 29, 2022 •

@mmarti @MoLow what do you think about reopening this for support for globs in --watch-path?

Would be great to only target certain file extensions, for example.

@MoLow MoLow reopened this Oct 29, 2022
@karlhorky
Copy link

karlhorky commented Oct 29, 2022 •

Thanks for reopening! Maybe the title can be changed to Support path globs with `--watch-path` ? And I suppose the issue description text will also need to be adapted a bit...

@MoLow MoLow changed the title Support optional file globs with --watch Support file globs with --watch-path Oct 29, 2022
@MoLow
Copy link
Member

MoLow commented Oct 29, 2022

Refs: #40731

@github-actions
Copy link
Contributor

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Apr 28, 2023
@karlhorky
Copy link

I guess this one is still validly open, and just because it hasn't had activity, doesn't seem like that is a reason that it won't be implemented... 🤔

Probably will be a pretty common request as more people use the watch mode in the Node.js CLI.

@github-actions
Copy link
Contributor

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Oct 26, 2023
@karlhorky
Copy link

not stale

@github-actions github-actions bot removed the stale label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. watch-mode Issues and PRs related to watch mode
Projects
Status: Pending Triage
Development

No branches or pull requests

2 participants