inspectLocalTarget(specifier: string): Promise<LocalTarget>
Reports what a resolved specifier points at, before anything is run on it.
Called once per invocation, ahead of discovery, so that a directory is
refused before deno doc gets a chance to answer about a module nobody
asked about. A non-file: specifier is "elsewhere" and touches no
filesystem.
Every way of failing to answer is a LocalTarget, including a
file: specifier that will not parse as a URL: binstruct "file://a b/x"
used to escape as an uncaught TypeError and a stack trace, because the URL
was decoded outside the try that guards the stat.
A module, a directory and a registry specifier
A module, a directory and a registry specifier
import { assertEquals } from "@std/assert"; import { inspectLocalTarget } from "./target.ts"; const module = await inspectLocalTarget(import.meta.resolve("./target.ts")); assertEquals(module.kind, "module"); const directory = await inspectLocalTarget(import.meta.resolve("./")); assertEquals(directory.kind, "directory"); if (directory.kind === "directory") { assertEquals(directory.modules.includes("target.ts"), true); assertEquals(directory.modules.includes("deno.json"), false); } assertEquals((await inspectLocalTarget("jsr:@binstruct/png")).kind, "elsewhere");
Promise<LocalTarget>
What is at the target, or "elsewhere" when it is not on this machine