Ensure flyctl is installed before running Mix tasks

This commit is contained in:
Claudio Ortolina
2024-12-01 12:32:21 +00:00
parent c4cafa0bf6
commit 53d2082ad0
+16 -2
View File
@@ -1,9 +1,23 @@
defmodule Mix.Tasks.MusicLibrary.Prod.Helpers do
def fly_ssh(command) do
System.cmd("flyctl", ["ssh", "console", "--command", command], into: IO.stream())
if flyctl_installed?() do
System.cmd("flyctl", ["ssh", "console", "--command", command], into: IO.stream())
else
IO.puts("Please install flyctl first")
System.halt(1)
end
end
def fly_sftp_get(remote_path, local_path) do
System.cmd("flyctl", ["ssh", "sftp", "get", remote_path, local_path], into: IO.stream())
if flyctl_installed?() do
System.cmd("flyctl", ["ssh", "sftp", "get", remote_path, local_path], into: IO.stream())
else
IO.puts("Please install flyctl first")
System.halt(1)
end
end
defp flyctl_installed?() do
System.find_executable("flyctl")
end
end