From f49b997a2849aff4965e79eafbc8dd9093e5333d Mon Sep 17 00:00:00 2001 From: Alexandre Hamez Date: Wed, 27 Nov 2024 18:42:00 +0100 Subject: [PATCH] feat: use System.tmp_dir() rather than Mix.Project.build_path() Useful when using protox in Livebook, as Mix.Project.build_path() returns an invalid path. --- lib/protox.ex | 2 +- lib/protox/protoc.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/protox.ex b/lib/protox.ex index 1f8804b..5092016 100644 --- a/lib/protox.ex +++ b/lib/protox.ex @@ -241,7 +241,7 @@ defmodule Protox do case Keyword.pop(opts, :schema) do {<>, opts} -> filename = "#{Base.encode16(:crypto.hash(:sha, text))}.proto" - filepath = [Mix.Project.build_path(), filename] |> Path.join() |> Path.expand() + filepath = [System.tmp_dir!(), filename] |> Path.join() |> Path.expand() File.write!(filepath, text) {[filepath], opts} diff --git a/lib/protox/protoc.ex b/lib/protox/protoc.ex index 86bbb2e..20be56b 100644 --- a/lib/protox/protoc.ex +++ b/lib/protox/protoc.ex @@ -25,7 +25,7 @@ defmodule Protox.Protoc do defp do_run(proto_files, args) do outfile_name = "protox_#{random_string()}" - outfile_path = Path.join([Mix.Project.build_path(), outfile_name]) + outfile_path = Path.join([System.tmp_dir!(), outfile_name]) cmd_args = ["--include_imports", "-o", outfile_path] ++ args ++ proto_files