FlamingTempura / bibtex-tidy

Cleaner and Formatter for BibTeX files
https://flamingtempura.github.io/bibtex-tidy/
MIT License
859 stars 66 forks source link

Specifying `args` in `pre-commit-config.yaml` causes no formatting (and no output) #419

Closed 34j closed 1 month ago

34j commented 10 months ago
repos:
  - repo: https://github.com/FlamingTempura/bibtex-tidy
    rev: v1.11.0
    hooks:
      - id: bibtex-tidy
        args: [--no-align]
pre-commit run -a

image However, the file is not formatted. If args is not specified, it works perfectly. Simlar: #409, Related: #14

artpelling commented 10 months ago

Facing the same problem..

artpelling commented 10 months ago

I've tried to find out what happens, did not really get to the bottom of it. I am now using version 1.9.0 as a workaround which works as expected.

34j commented 10 months ago

You are right, I tried it and confirmed that it does not work with 1.10.0 and works with 1.9.0. I have also tried the CLI, and the following commands seem to work correctly and I could not determine the cause.

npx -g install bibtex-tidy
bibtex-tidy --no-align test.bib
bibtex-tidy test.bib --no-align
bibtex-tidy "test.bib" "--no-align"   
flying-sheep commented 6 months ago

I stepped into pre-commit, and the command being run is

(
  '~/.cache/pre-commit/reponbqhr4ak/node_env-default/bin/node',
  '~/.cache/pre-commit/reponbqhr4ak/node_env-default/bin/bibtex-tidy',
  *args,
  file_path,
)

If I remove the ~/.cache/.../node from the start, it works.

So the problem is that bibtex-tidy doesn’t parse its command line arguments correctly when run running it using node path/to/bibtex-tidy ...args.

FlamingTempura commented 1 month ago

Fixed in v1.14.0 - the following should work:

repos:
-   repo: https://github.com/FlamingTempura/bibtex-tidy
    rev: v1.14.0
    hooks:
    -   id: bibtex-tidy
        args: ['--align=10', '--curly']