UNPKG

snapshot-fs

Version:

Create a filesystem snapshot for use with memfs

54 lines 1.9 kB
/** * Provides {@link createCJSONSnapshot} which creates a memfs snapshot from the * filesystem * * @module snapshot-fs/snapshot * @see {@link https://github.com/streamich/memfs/blob/master/docs/snapshot/index.md} */ import { type Volume } from 'memfs'; import { type JsonUint8Array, type SnapshotNode } from 'memfs/lib/snapshot/index.js'; import nodeFs from 'node:fs'; import { type sep } from 'node:path'; import { type CborUint8Array } from "./types.js"; /** * All files will be relative to this path in the output * {@link memfs DirectoryJSON} object */ export declare const DEFAULT_MEMFS_ROOT = "/"; /** * Options for {@link createCJSONSnapshot} */ export interface CreateSnapshotOptions { /** * Filesystem API */ fs?: FsApi; separator?: typeof sep; /** * Source to snapshot */ source?: string; } export type FsApi = typeof nodeFs | Volume; /** * Creates a CBOR snapshot from the `from` path using the filesystem API `fs`. * * @param opts Options for creating the snapshot * @returns A promise that resolves to the snapshot */ export declare function createCBORSnapshot({ fs, source: path, }?: CreateSnapshotOptions): Promise<CborUint8Array<SnapshotNode>>; /** * Creates a CJSON snapshot from the `from` path using the filesystem API `fs`. * * @param opts Options for creating the snapshot * @returns A promise that resolves to the snapshot */ export declare function createCJSONSnapshot({ fs, separator, source: path, }?: CreateSnapshotOptions): Promise<JsonUint8Array<SnapshotNode>>; /** * Creates a CJSON snapshot from the `from` path using the filesystem API `fs`. * * @param opts Options for creating the snapshot * @returns A promise that resolves to the snapshot */ export declare function createJSONSnapshot({ fs, separator, source: path, }?: CreateSnapshotOptions): Promise<string>; //# sourceMappingURL=snapshot.d.ts.map