From 656d83214defe80dfbc5ca89469fa0ab1e3aa541 Mon Sep 17 00:00:00 2001 From: isaac yonemoto Date: Sun, 4 Aug 2024 22:04:29 -0500 Subject: [PATCH] unifies os_info between zig_get and zigler --- .github/workflows/macos.yml | 2 +- installer/mix.tasks/zig.get.ex | 26 ++++++++++++++------------ lib/zig/command.ex | 12 +----------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 6c3de7a1..3f2b725b 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -46,5 +46,5 @@ jobs: - name: Run Tests env: RUNNING_CI: "true" - CI_LOG_LEVEL: "info" + CI_LOG_LEVEL: warning run: mix test --exclude no_ci \ No newline at end of file diff --git a/installer/mix.tasks/zig.get.ex b/installer/mix.tasks/zig.get.ex index 2003ab5a..c0499fce 100644 --- a/installer/mix.tasks/zig.get.ex +++ b/installer/mix.tasks/zig.get.ex @@ -1,3 +1,16 @@ +defmodule Zig.Get do + def os_info do + :system_architecture + |> :erlang.system_info() + |> to_string + |> String.split("-") + |> decode_os_info() + end + + defp decode_os_info([arch, "apple" | _]), do: {"macos", arch} + defp decode_os_info([arch, _vendor, os | _]), do: {os, arch} +end + defmodule Mix.Tasks.Zig.Get do use Mix.Task @@ -88,7 +101,7 @@ defmodule Mix.Tasks.Zig.Get do @default_version Zig.Get.MixProject.project()[:version] defp defaults do - {os, arch} = os_info() + {os, arch} = Zig.Get.os_info() %__MODULE__{ version: @default_version, @@ -98,17 +111,6 @@ defmodule Mix.Tasks.Zig.Get do } end - defp os_info do - :system_architecture - |> :erlang.system_info() - |> to_string - |> String.split("-") - |> decode_os_info() - end - - defp decode_os_info([arch, "apple" | _]), do: {"macos", arch} - defp decode_os_info([arch, _vendor, os | _]), do: {os, arch} - defp ensure_tar(%{os: "windows"} = opts), do: opts defp ensure_tar(opts) do diff --git a/lib/zig/command.ex b/lib/zig/command.ex index 1a3a14fb..b3c49c5b 100644 --- a/lib/zig/command.ex +++ b/lib/zig/command.ex @@ -165,7 +165,7 @@ defmodule Zig.Command do end defp versioned_path(path) do - {os, arch} = os_info() + {os, arch} = Zig.Get.os_info() zig_executable = Path.join(path, "zig-#{os}-#{arch}-#{@default_version}/zig") @@ -174,16 +174,6 @@ defmodule Zig.Command do if File.exists?(zig_executable), do: zig_executable end - defp os_info do - :system_architecture - |> :erlang.system_info() - |> to_string - |> String.split("-") - |> decode_os_info() - end - - defp decode_os_info([arch, _vendor, os | _]), do: {os, arch} - defp src_lib_name(module) do case {Target.resolve(), :os.type()} do {nil, {:unix, :darwin}} ->