mfs
mfs
(micro-fs) is a nodejs fs wrapper that provides a collection of high-level functions for manipulating files and directories.
Installation
npm install @cher-ami/mfs
Usage
import { * as mfs } from '@cher-ami/mfs';
(async () => {
await mfs.createFile('/test/foo.txt', 'Hello World');
const content = await mfs.readFile('/test/foo.txt');
console.log(content);
})();
API
function fileExists(path: string): Promise<boolean>
function createFile(path: string, content?: string): Promise<void>
function readFile(path: string): Promise<string>
function removeFile(path: string): Promise<boolean>
function copyFile(
src: string,
dest: string,
{
transform,
force,
}: { transform?: (content: string) => Promise<string>; force?: boolean }
): Promise<void>
function dirExists(path: string): Promise<boolean>
function readDir(path: string, recursive = true): Promise<string[]>
function removeDir(path: string): Promise<void>
function createDir(path: string): Promise<string | undefined>
function copyDir(
src: string,
dest: string,
{ force }: { force?: boolean } = {}
): Promise<void>
License
MIT
Credits
© Willy Brauner