-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Add watch option to lint commands #26120
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
Conversation
52602bf
to
cdbec19
Compare
|
||
declare(strict_types=1); | ||
|
||
/* |
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.
this should be changed
@@ -0,0 +1,35 @@ | |||
<?php | |||
|
|||
declare(strict_types=1); |
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.
we don't use strict_types atm in the codebase ATM
throw new \RuntimeException('The symfony/filesystem package is required in order to watch files for changes.'); | ||
} | ||
|
||
$io->note('Watching files for changes'); |
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.
Maybe a final dot or a ...
?
It might be worth opening an RFC issue to identify whether this makes sense to include this in Symfony. I would argue it is but still, it needs to be discussed :) |
3c2efa3
to
9961be3
Compare
What about splitting PR to two parts: first for adding watching for filesystem, second for lint commands? |
@@ -6,6 +6,7 @@ CHANGELOG | |||
|
|||
* The `FileDumper::setBackup()` method is deprecated and will be removed in 5.0. | |||
* The `TranslationWriter::disableBackup()` method is deprecated and will be removed in 5.0. | |||
* Added `--watch` option to the `lint:twig` command to watch the filesystem for changes and re-lint any changed files |
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.
lint:xliff
9961be3
to
d2acd0e
Compare
Would it make sense to have a single new |
I'm for having single command, but what's the best location to have it in? FileSystem component? |
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.
composer.json files need to be changed
@ostrolucky What must be changed? |
symfony/filesystem < 4.1 conflict section should be added. And maybe add it to suggest section |
Going through this PR again, I don't think adding a watch option for lint commands is a good use case. But the |
This PR actually has 2 parts:
watch
method to the Filesystem component to monitor the filesystem for changes, and executing a callback function whenever a change is detectedThe watch method can take any parameter and uses a resource locator to transform a path to a resource. The resource can then be monitored for any changes. When a directory is monitored, you can get changed events when a file in the directory changes, when a new file is created or when an existing file is deleted. It also tried to make usage of Inotify is the extension is installed.
Example usage:
When the
watch
option is used, the process will monitor the filesystem for any changes. When a change is detected, the changed file will be re-validated and the output printed to the console.