-module(go_over@hook). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([main/0]). -spec get_path() -> binary(). get_path() -> _pipe = simplifile:current_directory(), _pipe@1 = go_over@util@util:hard_fail( _pipe, <<"could not get current path"/utf8>> ), _pipe@2 = filepath:join(_pipe@1, <<".git"/utf8>>), filepath:join(_pipe@2, <<"hooks"/utf8>>). -spec main() -> {ok, nil} | {error, simplifile:file_error()}. main() -> Pwd = get_path(), _pipe = simplifile:create_directory_all(Pwd), go_over@util@util:hard_fail( _pipe, <<"could not create hooks directory"/utf8>> ), Pre_commit_path = filepath:join(Pwd, <<"pre-commit"/utf8>>), go_over@util@util:throwaway( go_over@util@util:has_flag( shellout_ffi:start_arguments(), <<"recreate"/utf8>> ), go_over@util@util:freeze1(fun simplifile:delete/1, Pre_commit_path) ), _ = simplifile:create_file(Pre_commit_path), All = gleam@set:from_list([read, write, execute]), _ = simplifile:set_permissions( Pre_commit_path, {file_permissions, All, All, All} ), simplifile:append( Pre_commit_path, <<"\n"/utf8, "gleam run -m go_over --target erlang"/utf8>> ).