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
We use an environment variable based tool stack. So it should be possible to skip specific lefthook commands by configure an environment variable, e.q. SOME_CHECK_ENABLED. We read about rc: in docs and found our use case:
Or if you want to use ENV variables that control the executables behaviour in lefthook.yml
Furthermore, based on the consumption that rc: exports all environment variables from an .env file, it should be possible to use skip from docs to skip a command like:
commands:
some:check:
skip:
- run: test "${SOME_CHECK_ENABLED}" = "false"run: ...
I hope my explanations are sufficient. I am grateful for any advice.
We also tried rc: <some_absolute_path>/lefthook.rc
lefthook install --force && lefthook --verbose run some-framework
Expected results
The environment variable SOME_CHECK_ENABLED processed in rc file lefthook.rc should be available in command's some:checkskip run to made the skip test.
Furthermore, the command's some:checkrun should also aware of these environment variables.
Change command some:check run to run: env for a test.
Hey @pschirch ! Does it work when you're running Git hooks? Is it important for you to have this rc file working for non-git hooks? Originally rc option was supposed to be used when you are using git in a IDE or your shell doesn't provide some environment variables required for your hooks.
Hey @mrexox ! Yap, running git hook by IDE triggers rc implementation correctly.
The lefthook.rc must contains the following configuration to work with .env from project root directory.
. "$(cd "$(dirname "$0")" && pwd)/../../.env"
Is it important for you to have this rc file working for non-git hooks?
Yes. We use lefthook as a task runner in our code quality stack and developers can run commands like lefthook run <framework>:(check|fix|test) independet from git lifecycle or staged area to be clear about their work. Sure, it is possible to autoload .env files by some workaround techniques, so lefthook always can work with that environment variables, but they often contains sensitive data, that should only isolated available in the specific running context.
It is possible to extend lefthookrc implementation also be available when running lefthook run ...?
🔧 Summary
We use an environment variable based tool stack. So it should be possible to skip specific lefthook commands by configure an environment variable, e.q.
SOME_CHECK_ENABLED
. We read aboutrc:
in docs and found our use case:Furthermore, based on the consumption that
rc:
exports all environment variables from an.env
file, it should be possible to useskip
from docs to skip a command like:I hope my explanations are sufficient. I am grateful for any advice.
Lefthook version
1.8.4
Steps to reproduce
.env
lefthook.rc
We also test
and
lefthook.yaml
lefthook install --force && lefthook --verbose run some-framework
Expected results
The environment variable
SOME_CHECK_ENABLED
processed in rc filelefthook.rc
should be available in command'ssome:check
skip run
to made the skip test.Furthermore, the command's
some:check
run
should also aware of these environment variables.Change command
some:check
run torun: env
for a test.Actual results
The environment variable
SOME_CHECK_ENABLED
is not available, theskip
test fails and the commandsome:check
will be executed.Possible Solution
Less a solution, more a workaround.
Source
. "$(cd "$(dirname "$0")" && pwd)/.env"
inskip run
every time.Logs / Screenshots
The text was updated successfully, but these errors were encountered: