jzaefferer / commitplease

Validates strings as commit messages
87 stars 17 forks source link

Allow skipping of hook at install time #111

Open Krinkle opened 4 years ago

Krinkle commented 4 years ago

Follows-up https://github.com/jzaefferer/commitplease/issues/36.

My dev environment for Node.js specifically mounts project directories in the isolation container with read-only access to .git for security reasons (details).

This means I'm currently unable to run npm install in e.g. qunit since it will fail mid-way on commitplease trying to install the hook.

Would you accept a PR that allows one to opt-out via an environment variable? It could be simple like COMMITPLEASE_NOHOOK=1. I also note that commitplease supports setting options via an .npmrc file. These are automatically read by npm into environment variables, e.g. npm_config_commitplease_nohook. If we read npmrc using that method instead, then it would naturally also allow toggling from the user's own environment variables.

I'm also open to other ways of toggling this. Let me know!

alisianoi commented 4 years ago

Hi,

Would you accept a PR that allows one to opt-out via an environment variable?

No comment, let's ping @jzaefferer to answer that. However, please bear in mind that you would also have the qunit project accept a version bump PR.

I also note that commitplease supports setting options via an .npmrc file.

That happens because the install.js script calls getOptions, which in turn inspects .npmrc and package.json files.

Generally, for the early abort there needs to be some kind of a check in install.js that will stop the copy of the hook, similar to the self-install check that is already there.