diff --git a/lib/nerves/env.ex b/lib/nerves/env.ex index bdedd936..93008e66 100644 --- a/lib/nerves/env.ex +++ b/lib/nerves/env.ex @@ -78,10 +78,9 @@ defmodule Nerves.Env do """ @spec data_dir() :: path :: String.t() def data_dir do - case {System.get_env("NERVES_DATA_DIR"), System.get_env("XDG_DATA_HOME")} do - {directory, _} when is_binary(directory) -> directory - {nil, directory} when is_binary(directory) -> :filename.basedir(:user_data, "nerves") - {nil, nil} -> Path.expand("~/.nerves") + case System.get_env("XDG_DATA_HOME") do + directory when is_binary(directory) -> :filename.basedir(:user_data, "nerves") + nil -> Path.expand("~/.nerves") end end diff --git a/test/nerves/env_test.exs b/test/nerves/env_test.exs index bcfeb637..2755eda9 100644 --- a/test/nerves/env_test.exs +++ b/test/nerves/env_test.exs @@ -61,20 +61,12 @@ defmodule Nerves.EnvTest do end describe "data_dir/0" do - test "prefers NERVES_DATA_DIR over XDG_DATA_HOME" do - System.put_env("NERVES_DATA_DIR", "nerves_data_dir") + test "XDG_DATA_HOME" do System.put_env("XDG_DATA_HOME", "xdg_data_home") - assert "nerves_data_dir" = Nerves.Env.data_dir() - end - - test "falls back to XDG_DATA_HOME/nerves" do - System.delete_env("NERVES_DATA_DIR") - System.put_env("XDG_DATA_HOME", "xdg_data_home") - assert :filename.basedir(:user_data, "nerves") == Nerves.Env.data_dir() + assert "xdg_data_home/nerves" = Nerves.Env.data_dir() end test "falls back to $HOME/.nerves" do - System.delete_env("NERVES_DATA_DIR") System.delete_env("XDG_DATA_HOME") assert Path.expand("~/.nerves") == Nerves.Env.data_dir() end diff --git a/test/support/test_case.ex b/test/support/test_case.ex index 09022774..dc6069fc 100644 --- a/test/support/test_case.ex +++ b/test/support/test_case.ex @@ -40,7 +40,7 @@ defmodule NervesTest.Case do fixture_to_tmp(which, dest) - System.put_env("NERVES_DATA_DIR", tmp_path(tmp)) + System.put_env("XDG_DATA_HOME", tmp_path(tmp)) try do File.cd!(dest, function)