Support changing directory before hook installation
See original GitHub issueBackground
I’m tinkering with adding a pre-commit hook for the wonderful Mega-Linter project (a Python/Docker/Node hard fork of the Shell-based GitHub Super-Linter).
The Mega-Linter has a Node CLI, however the package.json
for it lives in a mega-linter-runner
subdirectory of the root folder of Mega-Linter repo. This means, per the pre-commit Node docs, it can’t be installed:
The hook repository must have a package.json. It will be installed via
npm install .
Questions
-
Can the install hook be customized so that I can point at the subdirectory via hook metadata?
-
If not - what are my other options? The CLI mostly just wraps a Docker image, so I’ve gotten that to work directly with a
local
hook:repos: - repo: local hooks: - id: mega-linter name: Mega-Linter language: docker_image entry: -e DEFAULT_WORKSPACE=/src nvuillam/mega-linter:v4
I don’t love this experience though, as it breaks the abstraction layer of the CLI. I also think hooks are way more discoverable and adopted when there is a
.pre-commit-hooks.yaml
in the root of the repo, indicating a known method of use for pre-commit users, vs using alocal
hook.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
yeah that’s the breaks I guess 🤷 – if the upstream doesn’t want to support it they have every right not to. and if their tool is poorly designed / difficult to maintain that’s on them
additionally if your thing can’t be installed using the vanilla installation tools for the language it’s written in, there’s probably a bigger problem. adding complexity here pushes in the wrong direction (making this tool harder to maintain) instead of nudging maintainers towards making their tool easier to work with for everyone
I have no interest in getting into changing directories, environment variable substitution, installer flags, etc. – these are all error prone, difficult to configure, big potential for security issues, and for the 99% not necessary
Fair enough! And thank you for taking the time to respond.