我使用pre-commit,并且我有一个包含两个文件夹的存储库:
.
├── backend
│ └── (backend files)
├── frontend
│ └── (frontend files)
└── .pre-commit-config.yaml
每个文件夹都有一个 Dockerfile 并且彼此独立。
这是我的.pre-commit-config.yaml
:
repos:
- repo: local
hooks:
- id: go-docker
name: go
language: docker_image
entry: backend:latest go fmt
files: backend/
- id: prettier-docker
name: prettier
language: docker_image
entry: frontend:latest npm run format
files: frontend/
我想使用 Docker 在两个文件夹上运行预提交,但我得到:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /src/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/src/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
根据预提交文档:pre-commit will automatically mount the repository source as a volume using -v $PWD:/src:rw,Z and set the working directory using --workdir /src.
所以问题似乎是该frontend
文件夹位于src/frontend
但预提交使用的路径只是src
.
cd frontend
我在 Docker 命令之前尝试过,但没有运气。有任何想法吗?
提前致谢!