Skip to content
/ mfs Public
forked from willybrauner/mfs

A nodejs fs wrapper that provides some hight-level functions for manipulating files and directories.

Notifications You must be signed in to change notification settings

cher-ami/mfs

 
 

Repository files navigation

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

About

A nodejs fs wrapper that provides some hight-level functions for manipulating files and directories.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%