NodeFileProvider
Defined in: file-provider/node.ts:28
Node.js file provider
Example
Section titled “Example”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'Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NodeFileProvider(
basePath?):NodeFileProvider
Defined in: file-provider/node.ts:36
Create a Node.js file provider
Parameters
Section titled “Parameters”basePath?
Section titled “basePath?”string
Optional base path for relative paths (defaults to cwd)
Returns
Section titled “Returns”NodeFileProvider
Methods
Section titled “Methods”canonicalize()
Section titled “canonicalize()”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)
Parameters
Section titled “Parameters”filePath
Section titled “filePath”string
Returns
Section titled “Returns”string
Canonical path
Implementation of
Section titled “Implementation of”readText()
Section titled “readText()”readText(
filePath):Promise<string>
Defined in: file-provider/node.ts:40
Read file contents as UTF-8 text
Parameters
Section titled “Parameters”filePath
Section titled “filePath”string
Returns
Section titled “Returns”Promise<string>
File contents as string
Throws
Section titled “Throws”FileNotFoundError if file doesn’t exist
Throws
Section titled “Throws”FileReadError if file cannot be read
Implementation of
Section titled “Implementation of”resolve()
Section titled “resolve()”resolve(
fromFile,relativePath):string
Defined in: file-provider/node.ts:55
Resolve a relative path from a source file’s location
Parameters
Section titled “Parameters”fromFile
Section titled “fromFile”string
Canonical path of the file containing the reference
relativePath
Section titled “relativePath”string
Relative path to resolve (e.g., ”./foo.md”, ”../bar.md”)
Returns
Section titled “Returns”string
Canonical resolved path