-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
feat(unstable): Support --watch flag for bundle and fmt subcommands #8276
feat(unstable): Support --watch flag for bundle and fmt subcommands #8276
Conversation
I also added |
Just added |
|
@bartlomieju |
I added tests for
|
hmmm..... tests are sooooo flaky :( |
@magurotuna are you talking about tests for this PR or tests in general? |
@bartlomieju
I have no idea why |
@magurotuna thanks for detailed description. I'm aware of the first problem, but haven't found the reason yet. Second failure seems like an intermittent failure. As for third I'm not sure, let's keep a close eye on it. |
Several times of resolving conflict have been a little bit grunt work 😢 |
Sorry for that @magurotuna, I'll try to land your PR this weekend. Can I ask you to take a look at this comment and check if that's still the case? |
@bartlomieju Sure, I'll check for that. |
@magurotuna I've tested this PR locally and it's working very well! Code in this PR is a big improvement compared to current implementation and LGTM. Please prepare commit message before landing :) |
@bartlomieju
Sorry if I misunderstand it, but does it mean that you want me to write a commit message that will be used in a squashed merge commit? |
Yes, exactly |
@bartlomieju |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…enoland#8276) This commit adds support for "--watch" flag for "bundle" and "fmt" subcommands. In addition to this, it refactors "run --watch" command so that module resolution will occur every time the file watcher detects file addition/deletion, which allows the watcher to observe a file that is newly added to the dependency as well.
This PR adds
--watch
flag support for bothbundle
andfmt
subcommands.In addition to this, it refactors
run --watch
command so that module resolution will occur every time the file watcher detects file addition/deletion, which allows the watcher to observe a file that is newly added to the dependency as well.Fixes #8181
Currently,
--watch
flag is working withrun
only, but it is considered the flag is going to be added to other subcommands likefmt
,lint
, and so on. (see #7465)For this purpose, the current implementation of
watch_func
function has abstract, extendable design - all we have to do to add the watcher feature to subcommands is passing both target file paths and an operation you want to execute to thewatch_func
function.Considering it deeply, it seems like this
watch_func
design is not suitable for usecases, especiallyrun
subcommand. In case we want to detect file changes and then restart it, the watcher should also keep an eye on deletion and addition of files or dependency.So target file paths will vary, although the current
watch_func
receives constant file paths. This is why the issue described in #8181 happened.To address the issue, I think we should resolve dependency whenever the watcher detects changes. Actually this is relatively heavy task to be done every time, but it seems needed.
In this PR, I've added new watcher funtcion named
watch_func_for_run
which is dedicated torun
subcommand.Additionally I've removed the original
watch_func
function. I know this removal will have an effect on adding--watch
flag to other subcommands, which are being worked on at #7740 and #7767. I think other subcommands, likefmt
, also have the same issue asrun
. That said, if we would rundeno fmt --watch
, the watcher would have to detect any addition or deletion of files. Therefore we should probably consider again whatwatch_func
function interface should look like, without using the current one.TODO