Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
Smaller fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
XmiliaH committed Oct 20, 2021
1 parent 8b9d039 commit d03f150
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/contextify.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ Decontextify.object = (object, traps, deepTraps, flags, mock) => {
let def;

try {
def = host.Object.getOwnPropertyDescriptor(object, prop);
def = local.Object.getOwnPropertyDescriptor(object, prop);
} catch (e) {
throw Decontextify.value(e);
}
Expand Down Expand Up @@ -358,7 +358,7 @@ Decontextify.object = (object, traps, deepTraps, flags, mock) => {
}
if (!desc.configurable) {
try {
def = host.Object.getOwnPropertyDescriptor(target, prop);
def = local.Object.getOwnPropertyDescriptor(target, prop);
if (!def || def.configurable || def.writable !== desc.writable) {
local.Reflect.defineProperty(target, prop, desc);
}
Expand Down
8 changes: 6 additions & 2 deletions lib/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ return ((vm, host) => {

const code = host.STRICT_MODULE_PREFIX + contents + host.MODULE_SUFFIX;

const ccode = vm._hook('run', [code]);
const ccode = vm._hook('run', host.Array.of(code))[0];

// Precompile script
script = new Script(ccode, {
Expand Down Expand Up @@ -236,7 +236,11 @@ return ((vm, host) => {
return module.exports;
}

return Contextify.readonly(host.require(moduleName));
try {
return Contextify.readonly(host.require(moduleName));
} catch (e) {
throw new VMError(`Error loading '${moduleName}'`);
}
};

/**
Expand Down

0 comments on commit d03f150

Please sign in to comment.