From e0b9afb206a49b9a6b4122bfbe2ad097a147bf89 Mon Sep 17 00:00:00 2001 From: qgadrian Date: Tue, 3 Nov 2020 20:18:41 +0100 Subject: [PATCH] Ensure `/hooks` folder is created Fixes #62 --- lib/mix/tasks/git_hooks/install.ex | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/mix/tasks/git_hooks/install.ex b/lib/mix/tasks/git_hooks/install.ex index 62b14de..0ec3ff9 100644 --- a/lib/mix/tasks/git_hooks/install.ex +++ b/lib/mix/tasks/git_hooks/install.ex @@ -39,6 +39,7 @@ defmodule Mix.Tasks.GitHooks.Install do Printer.info("Installing git hooks...") + ensure_hooks_folder_exists() clean_missing_hooks() track_configured_hooks() @@ -111,10 +112,13 @@ defmodule Mix.Tasks.GitHooks.Install do Printer.warn( "Couldn't find git_hooks.db file, won't be able to restore old backups: #{inspect(error)}" ) + end - Printer.warn( - "Check that you are not missing `.git` folder, otherwise open a ticket at https://github.com/qgadrian/elixir_git_hooks/issues/new" - ) + @spec ensure_hooks_folder_exists() :: any + defp ensure_hooks_folder_exists do + Project.deps_path() + |> Path.join("/../.git/hooks") + |> File.mkdir_p() end @spec clean_missing_hooks() :: any