Skip to content

Commit

Permalink
feat: use System.tmp_dir() rather than Mix.Project.build_path()
Browse files Browse the repository at this point in the history
Useful when using protox in Livebook, as Mix.Project.build_path() returns an invalid path.
  • Loading branch information
ahamez committed Nov 27, 2024
1 parent af8759f commit f49b997
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/protox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ defmodule Protox do
case Keyword.pop(opts, :schema) do
{<<text::binary>>, 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}

Expand Down
2 changes: 1 addition & 1 deletion lib/protox/protoc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f49b997

Please sign in to comment.