Skip to content

Commit 5ac4829

Browse files
authoredMay 16, 2023
feat: support XDG_CONFIG_HOME (#1265)
1 parent ac2b52f commit 5ac4829

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed
 

‎husky.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ if [ -z "$husky_skip_init" ]; then
1414
exit 0
1515
fi
1616

17-
if [ -f ~/.huskyrc ]; then
18-
debug "sourcing ~/.huskyrc"
19-
. ~/.huskyrc
20-
fi
17+
for file in "$XDG_CONFIG_HOME/husky/init.sh" "$HOME/.config/husky/init.sh" "$HOME/.huskyrc.sh"; do
18+
if [ -f "$file" ]; then
19+
debug "sourcing $file"
20+
. "$file"
21+
break
22+
fi
23+
done
2124

2225
readonly husky_skip_init=1
2326
export husky_skip_init

5 commit comments

Comments
 (5)

sdavids commented on Nov 9, 2023

@sdavids

Could we maybe get a new release?

typicode commented on Nov 13, 2023

@typicode
OwnerAuthor

Working on it :)

No date though as I have some other ideas and things I'd like to prepare for the next release. I'm doing it when I have some free time (or when time is sponsored).

But I think, I'll publish it before 2024.

sdavids commented on Nov 13, 2023

@sdavids

typicode commented on Nov 13, 2023

@typicode
OwnerAuthor

So, the XDG’s default directory for XDG_CONFIG_HOME (~/.config) should be checked as well instead of only checking XDG_CONFIG_HOME.

Isn't that the case already with $HOME/.config/husky/init.sh check or am I misunderstanding?

One thing to have in mind is that on macOS the environment of UI applications is not the environment set up in your shell config (~/.zshrc).

That's what I meant here If you're running Git from an app and the command can be found in your terminal ... (https://typicode.github.io/husky/troubleshooting.html#command-not-found) but it may not be explicit enough? I didn't want to go into too much details about the OS. It can happen on Linux as well.

That said, I think that VSCode doesn't have this issue since it seems to run commands in the shell. So it's not all apps (not sure though).

Thanks for the feedback.

sdavids commented on Nov 13, 2023

@sdavids
Please sign in to comment.