prettier / prettier-emacs

Minor mode to format JS code on file save

Home Page:http://jlongster.com/A-Prettier-Formatter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Requires `diff` on Windows

kraai opened this issue · comments

When I installed prettier-emacs on Windows and saved a file with an incorrect style, the saved file still had the incorrect style. I did not see an error message displayed on the last line of the window. When I checked the contents of the *Messages* buffer, however, I saw that there was an error trying to run diff:

Saving file c:/Users/mkraai/src/calculator/online/server.js...
Wrote c:/Users/mkraai/AppData/Local/Temp/1/prettier9292Lab.js
Error: (file-error "Searching for program" "No such file or directory" "diff")
Wrote c:/Users/mkraai/src/calculator/online/server.js

Once I installed the MSYS version of diff, added the MSYS bin directory to my path, and restarted Emacs, the style was corrected when I saved the file.

I'm not sure how to fix this. Here are some possibilities:

  • Display an error indicating that diff couldn't be found when saving the file.
  • Note that diff is required in README.md.
  • Modify prettier-emacs to not require diff.

I would love if we were able to get rid of the diff dependency. Something I love about using emacs on Windows is that lisp "just works". When I used to use vim, I'd have to worry a lot about external commands and making sure they're installed.

Maybe there's a diff implementation in elisp that could be leveraged.

Could the diff function in diff.el be used?

Also as a temporary workaround, I think there's a port of GNU diff on Chocolatey.

Using @nickmccurdy suggesting to choco install diffutils solved the problem for me. It would be great if we didn't have to install that OR we could just update the docs and say that Windows users should do that.

@tgroshon do you mind doing a PR with the updated README?

thanks!

Absolutely. I will post one today.

Any update on this? I am running into prettier emacs issues as well

Can't believe I forgot to make a PR for that README.md change 🤦‍♂️
Just made one! The basic steps are as follows:

  1. Install Chocolatey: https://chocolatey.org/install
  2. Open an Admin Powershell session
  3. Install the diff program: choco install diffutils