datadesk / baker

A build tool by and for the Los Angeles Times
MIT License
21 stars 3 forks source link

git-pre-commit error preventing commits #1566

Closed vnessamartinez closed 6 months ago

vnessamartinez commented 6 months ago

I've forked and cloned the repo, but committing anything is throwing the following error. This only happens after running npm install or npm update. It seems to be related to the npm package precise-commits https://www.npmjs.com/package/precise-commits?activeTab=readme

git commit -m "test"  
△  run hook: pre-commit -> git-pre-commit
gi
> @datagraphics/baker@0.44.0 git-pre-commit /Users/mv/Code/web-components/baker
> precise-commits

t/Users/mv/Code/web-components/baker/node_modules/precise-commits/lib/precise-formatters/prettier.js:18
prettier_1.getSupportInfo().languages.forEach(function (language) {
                                     ^

TypeError: Cannot read property 'forEach' of undefined
    at Object.<anonymous> (/Users/mv/Code/web-components/baker/node_modules/precise-commits/lib/precise-formatters/prettier.js:18:38)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/Users/mv/Code/web-components/baker/node_modules/precise-commits/lib/index.js:15:18)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @datagraphics/baker@0.44.0 git-pre-commit: `precise-commits`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @datagraphics/baker@0.44.0 git-pre-commit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
palewire commented 6 months ago

Hmm. What version of node are you using? Could you try the following and post what you get?

node --version
palewire commented 6 months ago

I believe I fixed the issue with the patch in #1572. If you pull from the main branch and reinstall your npm dependencies I think it will work for you.

If my theory is correct, a dependabot upgrade to prettier version 3 introduced this error. I don't know the exact cause, but I suspect it is something about our configuration in the package.json file, or perhaps something in https://github.com/datadesk/prettier-config, that doesn't gell with the new version of prettier.

Addressing whatever that issue is may be required to upgrade to prettier in the future, but if this patch works for you now that's something.

palewire commented 6 months ago

Let me know how it goes. I hope this helps.

vnessamartinez commented 6 months ago

Thank you, @palewire. That worked!

palewire commented 6 months ago

Great to hear. If I can help with anything else let me know.