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
When running pnpm dlx husky init (or npx husky init) in a project with an existing prepare script in package.json, Husky overwrites it without any warning or prompt. This behavior can lead to the unintended loss of existing setup logic, which is particularly problematic in projects with multiple tools relying on the prepare script.
Steps to Reproduce
Create a package.json with an existing prepare script:
{
"scripts": {
"prepare": "cypress install"
}
}
Install Husky:
pnpm add -D husky
Run the init command:
pnpm dlx husky init
Check package.json after execution.
Expected Behavior
If a prepare script already exists, Husky should either:
Skip modifying package.json and log a message (e.g., "Existing prepare script detected, please manually add husky if needed").
Prompt the user to confirm whether to overwrite or merge the script.
Actual Behavior
The existing prepare script ("cypress install") is silently overwritten with "husky".
After running pnpm dlx husky init, package.json becomes:
{
"scripts": {
"prepare": "husky"
}
}
This removes the original cypress install command, breaking the project's setup workflow.
The text was updated successfully, but these errors were encountered:
Description
When running pnpm dlx husky init (or npx husky init) in a project with an existing prepare script in package.json, Husky overwrites it without any warning or prompt. This behavior can lead to the unintended loss of existing setup logic, which is particularly problematic in projects with multiple tools relying on the prepare script.
Steps to Reproduce
Create a package.json with an existing prepare script:
Install Husky:
Run the init command:
Check package.json after execution.
Expected Behavior
If a prepare script already exists, Husky should either:
Skip modifying package.json and log a message (e.g., "Existing prepare script detected, please manually add husky if needed").
Prompt the user to confirm whether to overwrite or merge the script.
Actual Behavior
The existing prepare script ("cypress install") is silently overwritten with "husky".
After running pnpm dlx husky init, package.json becomes:
This removes the original cypress install command, breaking the project's setup workflow.
The text was updated successfully, but these errors were encountered: