From 93d042a7c72c77584004644391a52c7d2ef6f8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Fri, 7 Jun 2024 20:56:15 +0200 Subject: [PATCH] Add Kino.beam_paths/0 (#439) --- lib/kino.ex | 12 ++++++++++++ lib/kino/bridge.ex | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/kino.ex b/lib/kino.ex index ee08045b..ac387e40 100644 --- a/lib/kino.ex +++ b/lib/kino.ex @@ -521,6 +521,18 @@ defmodule Kino do end end + @doc """ + Returns the directories that contain `.beam` files for modules + defined in the notebook. + """ + @spec beam_paths() :: list(String.t()) + def beam_paths() do + case Kino.Bridge.get_beam_paths() do + {:ok, paths} -> paths + _ -> [] + end + end + @doc """ Recompiles dependenies. diff --git a/lib/kino/bridge.ex b/lib/kino/bridge.ex index e43e1abb..d0d9f804 100644 --- a/lib/kino/bridge.ex +++ b/lib/kino/bridge.ex @@ -210,6 +210,14 @@ defmodule Kino.Bridge do with {:ok, reply} <- io_request(:livebook_get_tmp_dir), do: reply end + @doc """ + Returns directories with `.beam` files tied to the current runtime. + """ + @spec get_beam_paths() :: {:ok, String.t()} | {:error, :not_available} | request_error() + def get_beam_paths() do + with {:ok, reply} <- io_request(:livebook_get_beam_paths), do: reply + end + @doc """ Starts monitoring clients presence from the given process.