mirror of https://github.com/embarklabs/embark.git
feat: code runner use fs overrided
This commit is contained in:
parent
a147e2706b
commit
944b392cc5
|
@ -1,10 +1,13 @@
|
||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
|
const fs = require('../../fs');
|
||||||
|
|
||||||
class RunCode {
|
class RunCode {
|
||||||
constructor({logger}) {
|
constructor({logger}) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
const newGlobal = Object.create(global);
|
||||||
|
newGlobal.fs = fs;
|
||||||
this.context = Object.assign({}, {
|
this.context = Object.assign({}, {
|
||||||
global, console, exports, require, module, __filename, __dirname, process,
|
global: newGlobal, console, exports, require, module, __filename, __dirname, process,
|
||||||
setTimeout, setInterval, clearTimeout, clearInterval
|
setTimeout, setInterval, clearTimeout, clearInterval
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue