From 32babe4564d809b9b775bfb82cbfa5d018a6f487 Mon Sep 17 00:00:00 2001 From: Ihor Chulinda Date: Thu, 8 Feb 2018 11:27:08 +0100 Subject: [PATCH] fix(vm): adding missing chdir to vm process --- packages/baset-vm/dist/sandbox.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/baset-vm/dist/sandbox.js b/packages/baset-vm/dist/sandbox.js index a9632dc4..3a513393 100644 --- a/packages/baset-vm/dist/sandbox.js +++ b/packages/baset-vm/dist/sandbox.js @@ -347,6 +347,7 @@ return ((vm, host) => { return null; }; + let processCwd; global.process = { argv: [], title: host.process.title, @@ -359,7 +360,7 @@ return ((vm, host) => { features: Contextify.readonly(host.process.features), nextTick(callback) { return host.process.nextTick(() => callback.call(null)); }, hrtime() { return host.process.hrtime(); }, - cwd() { return host.process.cwd(); }, + cwd() {return processCwd || host.process.cwd(); }, on(name, handler) { if (name !== 'beforeExit' && name !== 'exit') { throw new Error(`Access denied to listen for '${name}' event.`); @@ -367,7 +368,10 @@ return ((vm, host) => { host.process.on(name, Decontextify.value(handler)); return this; - }, + }, + chdir(directory) { + processCwd = directory; + }, once(name, handler) { if (name !== 'beforeExit' && name !== 'exit') {