This package copies an in-memory file system created using memfs or unionfs to a local file system.
This package is available on the npm registry as memfs-mirror
.
npm install memfs-mirror
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);
- Any missing directories in the destination path will be automatically created.
- The destination path will not be automatically removed.
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.
This package is licensed under the Apache 2.0 License.