Skip to content

Commit e0b9afb

Browse files
committed
Ensure /hooks folder is created
Fixes #62
1 parent 78b0a9e commit e0b9afb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/mix/tasks/git_hooks/install.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ defmodule Mix.Tasks.GitHooks.Install do
3939

4040
Printer.info("Installing git hooks...")
4141

42+
ensure_hooks_folder_exists()
4243
clean_missing_hooks()
4344
track_configured_hooks()
4445

@@ -111,10 +112,13 @@ defmodule Mix.Tasks.GitHooks.Install do
111112
Printer.warn(
112113
"Couldn't find git_hooks.db file, won't be able to restore old backups: #{inspect(error)}"
113114
)
115+
end
114116

115-
Printer.warn(
116-
"Check that you are not missing `.git` folder, otherwise open a ticket at https://github.com/qgadrian/elixir_git_hooks/issues/new"
117-
)
117+
@spec ensure_hooks_folder_exists() :: any
118+
defp ensure_hooks_folder_exists do
119+
Project.deps_path()
120+
|> Path.join("/../.git/hooks")
121+
|> File.mkdir_p()
118122
end
119123

120124
@spec clean_missing_hooks() :: any

0 commit comments

Comments
 (0)