You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you have your editor instantly show changes from the filesystem? If not, how would save a file a file twice, since the second time there will have been changes to the file and you'll overwrite them? (My editor warns me about this and asks to confirm)
My editor automatically shows changes. It's fast enough that it doesn't cause me any issues for now. If the watch task only rebuilds the file I'm working on it should stay that way
Interesting, that's the opposite workflow from usual, where we have editor plugins that will automatically reformat on save. The editor invokes prettier before saving, formats it, and then it's saved.
My experience with watchers has always been painful trying to get them working across operating systems. Is there any reason you don't want to have the editor invoke prettier, @thejameskyle ? Which editor are you using?
@thejameskyle fwiw, many of the editor integrations also invoke the script from scratch. I think atom is the only one that doesn't because it's written in JS and already supports JS APIs first-class.
A more generic solution might be to introduce a "server" mode that just spawns it in the background and anything can run the CLI as many times as it wants. This would benefit all editors as well as your watch mode. Not sure how much more complex that would be, or if there's already a node module to help with that though.
I'm doing a spring cleaning of the issues and we're unlikely going to implement it, so closing. If someone is interested in building this, there is no opposition.
@vjeux - I thought perhaps it might be nice to put in the README how to use this with an [external] watcher - that way it hopefully will please everyone wanting a watcher, without having requests to reimplement this functionality in the code of Prettier.
Thoughts? I made pull request #3126 if you want it.
For those who are coming here from Google wanting this functionality, the short version is:
Activity
vjeux commentedon Feb 2, 2017
I wish there was a unix utility for that instead of each project having to reimplement it in a crappy way :(
xtuc commentedon Feb 2, 2017
@vjeux there is actually unix
inotifybut you will still need some sort of Node binding.vjeux commentedon Feb 2, 2017
@xtuc I was more thinking about
jamiebuilds commentedon Feb 2, 2017
I am using https://github.com/mikeal/watch to do effectively that:
The problem is that it will just spawn up a new prettier process and go through every single file again
xtuc commentedon Feb 2, 2017
Yeah that would be awesome.
lydell commentedon Feb 2, 2017
There's also cli-watch and chokidar-cli. Example:
jlongster commentedon Feb 2, 2017
Do you have your editor instantly show changes from the filesystem? If not, how would save a file a file twice, since the second time there will have been changes to the file and you'll overwrite them? (My editor warns me about this and asks to confirm)
jamiebuilds commentedon Feb 2, 2017
My editor automatically shows changes. It's fast enough that it doesn't cause me any issues for now. If the watch task only rebuilds the file I'm working on it should stay that way
jlongster commentedon Feb 2, 2017
Interesting, that's the opposite workflow from usual, where we have editor plugins that will automatically reformat on save. The editor invokes prettier before saving, formats it, and then it's saved.
My experience with watchers has always been painful trying to get them working across operating systems. Is there any reason you don't want to have the editor invoke prettier, @thejameskyle ? Which editor are you using?
jamiebuilds commentedon Feb 2, 2017
Because I want it to run out of the box for everyone working on the project
xtuc commentedon Feb 2, 2017
With Vim, i'm not notified that the file has changed unless I try to save. If I really save I will just override my version with the formated one.
Prettify before save is actually a better solution in my case.
I know many other editors will just load the new version of the file you're currently on.
jlongster commentedon Feb 3, 2017
@thejameskyle fwiw, many of the editor integrations also invoke the script from scratch. I think atom is the only one that doesn't because it's written in JS and already supports JS APIs first-class.
A more generic solution might be to introduce a "server" mode that just spawns it in the background and anything can run the CLI as many times as it wants. This would benefit all editors as well as your watch mode. Not sure how much more complex that would be, or if there's already a node module to help with that though.
jamiebuilds commentedon Feb 3, 2017
You might find this useful: http://langserver.org/
baransu commentedon Feb 14, 2017
If you want quick unix tool without implementing it into package I recommend entr.
olpeh commentedon Mar 10, 2017
FYI: It tried using prettier together with npm-watch but it wrote the files as empty.
Tried using https://github.com/mikeal/watch instead as @thejameskyle suggested and it seems to work.
This is good enough at least for me.
vjeux commentedon Mar 10, 2017
@olpeh: could you create a test plan that reproduces the issue? This way we can look into it.
olpeh commentedon Mar 10, 2017
@vjeux Sure. Should I create a new issue of that or add it here?
Is there a template I should follow?
vjeux commentedon Mar 10, 2017
A new issue would be great. No template, just make sure there's enough information so that we can investigate :)
Add prettier_d to Related Projects
Add prettier_d to Related Projects (#1328)
vjeux commentedon May 21, 2017
I'm doing a spring cleaning of the issues and we're unlikely going to implement it, so closing. If someone is interested in building this, there is no opposition.
eedrah commentedon Oct 31, 2017
@vjeux - I thought perhaps it might be nice to put in the README how to use this with an [external] watcher - that way it hopefully will please everyone wanting a watcher, without having requests to reimplement this functionality in the code of Prettier.
Thoughts? I made pull request #3126 if you want it.
For those who are coming here from Google wanting this functionality, the short version is: