mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-11-27 06:32:42 +00:00
25 lines
948 B
JavaScript
25 lines
948 B
JavaScript
/** Discover a freshly staged plugin without changing Obsidian's global vault registry. */
|
|
import assert from "node:assert/strict";
|
|
import { runInAppTask } from "./inAppTask.mjs";
|
|
export async function discoverStagedPlugin(cli, id) {
|
|
assert.ok(
|
|
["obsidian-excalidraw-plugin", "excalidraw-extras", "k-plex"].includes(id),
|
|
"Unowned plugin discovery target",
|
|
);
|
|
return runInAppTask({
|
|
cli,
|
|
args: [id],
|
|
execute: async (_c, id) => {
|
|
if (app.plugins.manifests[id]) return { discovery: "existing" };
|
|
if (typeof app.plugins.loadManifests !== "function")
|
|
throw Error(
|
|
"Host cannot discover staged plugins; open this owned vault once with the staged files before retrying",
|
|
);
|
|
await app.plugins.loadManifests();
|
|
if (app.plugins.manifests[id]?.id !== id)
|
|
throw Error("Staged plugin manifest was not discovered: " + id);
|
|
return { discovery: "refreshed" };
|
|
},
|
|
});
|
|
}
|