You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, my team is working on a project and at some point we decided to integrate husky. The thing is that our project is not located in the same directory as .git file. I managed to change prepare script from "scripts": { ..., "prepare": "husky" },
to "scripts": { ..., "prepare": "cd .. && husky frontend/.husky && cd frontend && npx husky init" },
and I created .husky/pre-commit file with cd frontend npx lint-staged
when running npm install it overwrites package.json and .husky/pre-commit files to default values. I created a fork of the husky repository and added a few lines to prevent overwriting those files. Like so:
// create a prepare script only if it doesn't exist
if (!o.scripts.prepare) {
;(o.scripts ||= {}).prepare = 'husky'
w(n, JSON.stringify(o, 0, /\t/.test(s) ? '\t' : 2) + '\n')
}
p.stdout.write(i())
try { f.mkdirSync('.husky') } catch {}
// create a pre-commit file with test command only if it doesn't exist
if (!e('.husky/pre-commit')) {
w('.husky/pre-commit', process.env.npm_config_user_agent.split('/')[0] + ' test\n');
}
it works well in our project. What do you think about adding those lines to the bin.mjs?
The text was updated successfully, but these errors were encountered:
Hello, my team is working on a project and at some point we decided to integrate husky. The thing is that our project is not located in the same directory as .git file. I managed to change prepare script from
"scripts": { ..., "prepare": "husky" },
to
"scripts": { ..., "prepare": "cd .. && husky frontend/.husky && cd frontend && npx husky init" },
and I created
.husky/pre-commit
file withcd frontend npx lint-staged
when running
npm install
it overwritespackage.json
and.husky/pre-commit
files to default values. I created a fork of the husky repository and added a few lines to prevent overwriting those files. Like so:it works well in our project. What do you think about adding those lines to the
bin.mjs
?The text was updated successfully, but these errors were encountered: