patriksimek / vm2

Advanced vm/sandbox for Node.js
MIT License
3.86k stars 293 forks source link

Added custom file system API #489

Closed XmiliaH closed 1 year ago

XmiliaH commented 1 year ago

Add a file system API to support file system such as memfs. Can be used like:

const {NodeVM, VMFileSystem} = require('vm2');
const memfs = require('memfs');

const fs = new VMFileSystem({fs: memfs});

const vm = new NodeVM({require: {fs: fs}});
elglogins commented 1 year ago

An example of how to use this, with f.x. running a script, that requires a relative path module file. Would be great.