-
Notifications
You must be signed in to change notification settings - Fork 29
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
Funny behavior with pre-commit and Windows #69
Comments
Welcome @spapas, and thank you for finally figuring out the cause of #66! Your solution by special-casing Windows executable filenames would work, but what would also work is to remove the I don't think many people are using |
Hello @JaapJoris the approach you propose is fine for me, however I'd really recommend to allow a flag for outputing to stdout. This would be important for testing purposes. Also please notice that if you remove the -i flag it may break some people's workflows. |
@spapas I think @JaapJoris suggested to make it a default and not remove it? |
@GitRon how would the -i flag be the default without removing it ? |
Oh, sorry, misread it. But the issue could be solved with publishing a major release, right? So people get the indication that something happened. |
The main use case of DjHTML is to modify files in-place. Therefore, the `-i` (`--in-place`) argument has been made the default and removed, leaving only a deprecation error. The `-o` (`--output-file`) argument has also been removed. Reading from standard input and writing to standard output is still supported by using "-" as the filename. By the same mechanism, writing the output to a different file is also still possible by using output redirection: djhtml - < input.html > output.html Since this is a backwards-incompatible change, the next release will increment the major version number. No changes have been made to the indentation algorithm. Closes #66 Closes #69 Closes #70
@JaapJoris Awesome! Any plans for when the new release will come out? |
@GitRon Very soon! |
Finally, note there is actually a reason for the default mode being
Since the module is called |
Hello @JaapJoris seems to be working fine now on my windows system! Thank you |
Hello, I was using the following snippet for pre-commit:
rev: v1.5.2
hooks:
entry: djhtml -i -t 2
entry: djcss -i -t 2
entry: djjs -i -t 2
This resulted in removing the identation of the css and js files when pre-commit was run (similar to this issue #66).
When I tried running
djcss file.css
ordjjs file.js
it worked fine but when it was run through pre-commit it removed the identation!After some tests, I changed my hooks to :
and now it works! My understanding is that when the djcss/djjs scripts are run through pre-commit it can't match their filenames and falls back upon the djhtml which seems to be the default (see here https://github.com/rtts/djhtml/blob/main/djhtml/__main__.py#L34) ?
One possible solution would be to change the corresponding lines (
djhtml/djhtml/__main__.py
Line 34 in 295a54c
if sys.argv[0].endswith("djtxt") or sys.argv[0].endswith("djtxt.exe"):
. However I can't easily test it since I don't know how to generate these .exe files and I understand that if you don't use windows it also wouldn't be easy for you to test...Another simpler solution would be to add a hint for Windows devs in the README.md (i.e windows users should always add the
enrty: djjs.exe -i
and djcss.exe lines)The text was updated successfully, but these errors were encountered: