@cher-ami/mfs
v0.2.0
Published
nodejs fs wrapper
Downloads
1,550
Keywords
Readme
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 () => {
// create a new file in a non-existing directory
await mfs.createFile('/test/foo.txt', 'Hello World');
const content = await mfs.readFile('/test/foo.txt');
console.log(content); // -> "Hello World"
})();
API
- fileExists
function fileExists(path: string): Promise<boolean>
- createFile
function createFile(path: string, content?: string): Promise<void>
- readFile
function readFile(path: string): Promise<string>
- removeFile
function removeFile(path: string): Promise<boolean>
- copyFile
function copyFile(
src: string,
dest: string,
{
transform,
force,
}: { transform?: (content: string) => Promise<string>; force?: boolean }
): Promise<void>
- dirExists
function dirExists(path: string): Promise<boolean>
- readDir
function readDir(path: string, recursive = true): Promise<string[]>
- removeDir
function removeDir(path: string): Promise<void>
- createDir
function createDir(path: string): Promise<string | undefined>
- copyDir
function copyDir(
src: string,
dest: string,
{ force }: { force?: boolean } = {}
): Promise<void>
License
MIT
Credits
© Willy Brauner