function Dir
Dir<D extends Dir>(...entries: DirEntry<D>[]): DirEntry<D>

Specify a directory.

Takes an optional subpath, then one or more callbacks.

Returns function which creates directory at specified subpath, then pipes it through the callbacks.

Example: const makeEmptyDir = Dir('foo'); await makeEmptyDir(); // created "./foo/"

const makeDirWithFiles = Dir('foo', Txt('hello.txt', 'world'));
await makeDirWithFiles({ cwd: '/path/to/somewhere/' });
// created "/path/to/somewhere/foo/hello.txt" and wrote "world'

Type Parameters

D extends Dir

Parameters

...entries: DirEntry<D>[]

Return Type

Dir<D extends Dir>(
subpath: string,
...entries: DirEntry<D>[],
): DirEntry<D>

Type Parameters

D extends Dir

Parameters

subpath: string
...entries: DirEntry<D>[]

Return Type

type alias Dir

A directory.

Properties

path: string
optional
tree: Record<string, unknown>
optional
mkdir: (_: string) => Promise<unknown>
optional
mkdtemp: (_?: string) => Promise<unknown>
optional
rimraf: (_?: string) => Promise<unknown>
optional
writeFile: (
_: string,
__: string | Bytes,
enc?: "utf8",
) => Promise<unknown>