Skip to content

Old node_modules in koha code directory breaks prettier for .tt and .inc. Causes commit hook to commit empty files.

And thus loosing the changes. Without recovery from the stash or staging area.

The normal node_modules is inside the KTD image. But every time someone uses yarn directly. It creates another node_modules in the code directory. Which stays here and is included by node in its lib path.

Test plan:

  1. rm node_modules
  2. misc/devel/tidy.pl --no-write koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
  3. yarn run prettier --no-write koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
  4. they output as expected
  5. git checkout 2bf41eb65d (an old commit from September)
  6. yarn install
  7. git checkout main
  8. yarn run prettier --no-write koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
  9. misc/devel/tidy.pl --no-write koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
  10. no output
  11. make a change to a .tt file, try to commit and abort with an empty commit message
  12. See the staged file is empty 😱 😱 😱 😱 😱 😱 😱
  13. clean up the commit attempt
  14. rm node_modules or yarn install # to not have anyone outdated js libs
  15. prettier, tidy.pl and commiting .tt changes should work again

Ideas to fix: The hook might want to ensure prettier returns something and abort it empty. Or just warn that tidy will be skipped and commit anyway.

There is also hope that if the result of Bug 36682 (https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36682) is fast enough we don't have to bake the js libs in the KTD image. No duplication.

Other ideas?