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

Add option to watch all files in a directory. #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davnn
Copy link

@davnn davnn commented Apr 14, 2020

Hey!

This pull request adds an option to watch for all file changes in the specified or default directory.

-w, --watch

Watches all files in the specified or default directory and triggers a reload if files change.

To work with the current working directory we have to ignores some common paths that may exist there (node_modules, .git, ...). Let's discuss what paths we should ignore by default or if we should only allow watching subdirectories.

@netlify
Copy link

netlify bot commented Apr 14, 2020

Deploy request for elm-live pending review.

Review with commit 7080acc

https://app.netlify.com/sites/elm-live/deploys

@davnn
Copy link
Author

davnn commented Apr 14, 2020

Adresses #196

@davnn davnn mentioned this pull request Apr 14, 2020
ignoreInitial: true,
followSymlinks: false,
ignored: ['elm-stuff/generated-code/*', /ElmjutsuDumMyM0DuL3.elm/, /\/.#[^/]+\.elm/]
ignored: [new RegExp(model.target), /.git/, /.vscode/, /.idea/, /node_modules/, /elm-stuff/, /ElmjutsuDumMyM0DuL3.elm/, /\/.#[^/]+\.elm/]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these new folders are "personal" to the developer, especially .vscode and .idea. For example, I might be using a different IDE that creates a different temp folder for caching, and the watcher will still listen to those files.
A solution would be check if there's a .gitignore file, read it, and filter the folders

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading .gitignore might lead to other problems, for example when you are generating ignored source files that should still trigger a reload.

We could just force --dir when using --watch or are there use cases where you have to watch the current working directory?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's true. Forcing the dist might help if you target another directory other than root, but if you still target the root then the problem will persist.
Maybe we can say "any path (file or folder) that starts with . + /node_modules/ etc, and a flag can be added, like --watchIgnore in case the user wants to ignore additional folders.

@TheWhitelock
Copy link

Are there still plans to merge this PR?

@davnn
Copy link
Author

davnn commented Mar 6, 2021

Are there still plans to merge this PR?

There was no consensus on how to implement this feature. Either we allow watching the root directory and add an option to ignore certain folders (e.g. --watchIgnore), or we disallow watching the root folder and force --dir). Maybe @wking-io has a preference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants