Skip to content

Commit

Permalink
fix(vm): adding missing chdir to vm process
Browse files Browse the repository at this point in the history
  • Loading branch information
Igmat committed Feb 8, 2018
1 parent c5a0fb7 commit 32babe4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/baset-vm/dist/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ return ((vm, host) => {
return null;
};

let processCwd;
global.process = {
argv: [],
title: host.process.title,
Expand All @@ -359,15 +360,18 @@ 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.`);
}

host.process.on(name, Decontextify.value(handler));
return this;
},
},
chdir(directory) {
processCwd = directory;
},

once(name, handler) {
if (name !== 'beforeExit' && name !== 'exit') {
Expand Down

0 comments on commit 32babe4

Please sign in to comment.