Skip to content

Have `memfs` but with single directories mounted from the native fs

Notifications You must be signed in to change notification settings

drinking-code/hybridfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hybridfs

Basically memfs, but you can mount directories from the native nodejs filesystem.
Install with:

npm i drinking-code/hybridfs

Use like:

import createHybridFs from 'hybridfs'

// create in-memory fs with "./node_modules" from the node:fs mounted to "/node_modules"
const hfs = createHybridFs([
    ['node_modules', '/node_modules']
])

hfs.writeFileSync('/foo', 'bar') // writes to the in-memory fs
console.log(
    hfs.readFileSync('/foo', 'utf8')
) // -> "bar"

Uses memfs' API (Node's fs API) for the file system.

Reference

createHybridFs(rewrites: (string | [string, string])[])

Create a hybrid file system. Accepts an array of mounts where one mount is either

  • a string: "/foo" mounts "/foo" from the native filesystem to "/foo" in the in-memory filesystem; or
  • an array of two strings: ["/foo", "/bar"] mounts "/foo" from the native filesystem to "/bar" in the in-memory filesystem.

Both types can be mixed in the array.

Returns a hybrid file system.

About

Have `memfs` but with single directories mounted from the native fs

Resources

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •