Skip to content

Copies an in-memory file system created using memfs or unionfs to a local file system.

License

Notifications You must be signed in to change notification settings

targendaz2/memfs-mirror

Repository files navigation

memfs-mirror

GitHub License GitHub package.json version NPM Version GitHub Actions Workflow Status

This package copies an in-memory file system created using memfs or unionfs to a local file system.

Installation

This package is available on the npm registry as memfs-mirror.

npm install memfs-mirror

Usage

Examples

import { vol } from 'memfs';
import { mirror } from 'memfs-mirror';

vol.fromJSON(
  {
    './file1.txt': 'Hello, world!',
    './sub-folder/file2.txt': 'Hello, sub-folder!',
  },
  '/memfs-volume',
);

// Asynchronous usage
await mirror('/memfs-volume', '/tmp/local-folder', vol);

// Synchronous usage
mirrorSync('/memfs-volume', '/tmp/local-folder', vol);

Notes

  • Any missing directories in the destination path will be automatically created.
  • The destination path will not be automatically removed.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

This package is licensed under the Apache 2.0 License.