Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/targendaz2/memfs-mirror

Copies an in-memory file system created using memfs or unionfs to a local file system.
https://github.com/targendaz2/memfs-mirror

filesystem in-memory memfs mirror sync unionfs virtual

Last synced: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# memfs-mirror

![GitHub License](https://img.shields.io/github/license/targendaz2/memfs-mirror)
![GitHub package.json version](https://img.shields.io/github/package-json/v/targendaz2/memfs-mirror)
![NPM Version](https://img.shields.io/npm/v/memfs-mirror?logo=npm&logoColor=%23999999)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/targendaz2/memfs-mirror/test.yml?logo=github&label=tests&logoColor=%23999999)

This package copies an in-memory file system created using [memfs](https://npmjs.com/package/memfs) or [unionfs](https://npmjs.com/package/unionfs) to a local file system.

## Installation

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

```bash
npm install memfs-mirror
```

## Usage

### Examples

```typescript
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](https://github.com/targendaz2/memfs-mirror/blob/main/LICENSE).