Skip to content

NodeFileProvider

Defined in: file-provider/node.ts:28

Node.js file provider

const provider = new NodeFileProvider();
const content = await provider.readText('/project/spec/index.md');
const resolved = provider.resolve('/project/spec/index.md', './intro.md');
// resolved === '/project/spec/intro.md'

new NodeFileProvider(basePath?): NodeFileProvider

Defined in: file-provider/node.ts:36

Create a Node.js file provider

string

Optional base path for relative paths (defaults to cwd)

NodeFileProvider

canonicalize(filePath): string

Defined in: file-provider/node.ts:68

Convert a path to its canonical form

Canonical paths are:

  • Absolute (no relative segments)
  • Normalized (no . or .. segments)
  • Consistent across platform (forward slashes for web/memory)

string

string

Canonical path

FileProvider.canonicalize


readText(filePath): Promise<string>

Defined in: file-provider/node.ts:40

Read file contents as UTF-8 text

string

Promise<string>

File contents as string

FileNotFoundError if file doesn’t exist

FileReadError if file cannot be read

FileProvider.readText


resolve(fromFile, relativePath): string

Defined in: file-provider/node.ts:55

Resolve a relative path from a source file’s location

string

Canonical path of the file containing the reference

string

Relative path to resolve (e.g., ”./foo.md”, ”../bar.md”)

string

Canonical resolved path

FileProvider.resolve