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:
- rm node_modules
misc/devel/tidy.pl --no-write koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
yarn run prettier --no-write koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
- they output as expected
-
git checkout 2bf41eb65d
(an old commit from September) yarn install
git checkout main
yarn run prettier --no-write koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
misc/devel/tidy.pl --no-write koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
- no output
- make a change to a .tt file, try to commit and abort with an empty commit message
- See the staged file is empty
😱 😱 😱 😱 😱 😱 😱 - clean up the commit attempt
- rm node_modules or yarn install # to not have anyone outdated js libs
- 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?