Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

husky.sh file generated by husky install becomes empty #1442

Closed
1 task done
JairTorres1003 opened this issue May 14, 2024 · 3 comments
Closed
1 task done

husky.sh file generated by husky install becomes empty #1442

JairTorres1003 opened this issue May 14, 2024 · 3 comments

Comments

@JairTorres1003
Copy link

Troubleshoot

If you're migrating from husky 4, see:
https://typicode.github.io/husky/migrate-from-v4.html

Context

Problem: When running npx husky install or npm run prepare, the husky.sh file within .husky/_ directory is left empty, causing hooks configured in the .husky directory to not function properly.

This is my package.json

{
  "version": "0.1.0",
  "private": true,
  "license": "MIT",
  "engines": {
    "node": ">=20.10.0"
  },
  "scripts": {
    "dev": "next dev",
    "build": "next build --no-lint",
    "start": "next start",
    "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
    "lint:fix": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix --cache",
    "format:check": "prettier --check \"**/*.{ts,tsx,json,css,md,cjs}\"",
    "format": "prettier --write \"**/*.{ts,tsx,json,css,md,cjs}\"",
    "prepare": "husky install"
  },
  "dependencies": {
    "@emotion/react": "^11.11.3",
    "@emotion/styled": "^11.11.0",
    "@fullcalendar/core": "^6.1.11",
    "@fullcalendar/react": "^6.1.11",
    "@fullcalendar/timegrid": "^6.1.11",
    "@mercadopago/sdk-react": "^0.0.18",
    "@mui/icons-material": "^5.15.10",
    "@mui/material": "^5.15.9",
    "@mui/x-date-pickers": "^7.1.1",
    "@reduxjs/toolkit": "^2.1.0",
    "@tiptap/extension-color": "^2.3.0",
    "@tiptap/extension-text-style": "^2.3.0",
    "@tiptap/pm": "^2.3.0",
    "@tiptap/react": "^2.3.0",
    "@tiptap/starter-kit": "^2.3.0",
    "axios": "^1.6.7",
    "dayjs": "^1.11.10",
    "leaflet": "^1.9.4",
    "localforage": "^1.10.0",
    "next": "14.1.1",
    "react": "^18",
    "react-dom": "^18",
    "react-google-recaptcha": "^3.1.0",
    "react-hook-form": "^7.50.1",
    "react-leaflet": "^4.2.1",
    "react-player": "^2.15.1",
    "react-redux": "^9.1.0",
    "react-responsive": "^10.0.0",
    "react-to-print": "^2.15.1",
    "redux-persist": "^6.0.0",
    "swiper": "^11.0.6",
    "universal-cookie": "^7.1.4",
    "zod": "^3.23.8"
  },
  "devDependencies": {
    "@types/leaflet": "^1.9.8",
    "@types/node": "^20.11.16",
    "@types/react": "^18.2.55",
    "@types/react-dom": "^18.2.19",
    "@types/react-google-recaptcha": "^2.1.9",
    "@typescript-eslint/eslint-plugin": "^7.5.0",
    "@typescript-eslint/parser": "^7.5.0",
    "eslint": "^8.56.0",
    "eslint-config-love": "^46.0.0",
    "eslint-config-next": "^14.1.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-config-standard": "^17.1.0",
    "eslint-plugin-import": "^2.29.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-prettier": "^5.1.3",
    "eslint-plugin-promise": "^6.1.1",
    "eslint-plugin-react": "^7.33.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.5",
    "husky": "^9.0.11",
    "lint-staged": "^15.2.2",
    "prettier": "^3.2.5",
    "typescript": "^5.3.3"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.{ts,tsx}": "eslint --cache --fix",
    "*.{ts,tsx,css,md,json}": "prettier --write"
  }
}

Steps to Reproduce:
Run npx husky install or npm run prepare to generate Husky configuration files.
Check the contents of the husky.sh file within the .husky/_ directory.

  • Terminal or GUI client: Git Bash, GitHub Desktop, VSCode
@typicode
Copy link
Owner

it has been replaced by .husky/_/h
.husky/_/husky.sh is still there as a transition to avoid breaking v8 hooks

@JairTorres1003
Copy link
Author

JairTorres1003 commented May 21, 2024

Ok, I understand the functionality does not change and remains the same, so if I leave this like this it works normally and no additional adjustments should be made.

.husky/pre-commit

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged

@JairTorres1003
Copy link
Author

It works like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants