mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-24 13:15:40 +00:00
wip: safe-mode updates
This commit is contained in:
@@ -104,6 +104,7 @@ class TestRuntime {
|
||||
log: customLogger('log'),
|
||||
info: customLogger('info'),
|
||||
warn: customLogger('warn'),
|
||||
debug: customLogger('debug'),
|
||||
error: customLogger('error')
|
||||
};
|
||||
}
|
||||
|
||||
@@ -100,14 +100,14 @@ const executeQuickJsVmAsync = async ({
|
||||
fn.apply();
|
||||
}
|
||||
await sleep(0);
|
||||
console?.debug && console.debug('quick-js:execution-start:');
|
||||
console?.debug?.('quick-js:execution-start:');
|
||||
try {
|
||||
${externalScript}
|
||||
}
|
||||
catch(error) {
|
||||
console?.debug && console.debug('quick-js:execution-end:with-error', error?.message);
|
||||
console?.debug?.('quick-js:execution-end:with-error', error?.message);
|
||||
}
|
||||
console?.debug && console.debug('quick-js:execution-end:');
|
||||
console?.debug?.('quick-js:execution-end:');
|
||||
return 'done';
|
||||
})()
|
||||
`;
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
const addConsoleShimToContext = (vm, console) => {
|
||||
if (!console) return;
|
||||
|
||||
const consoleHandle = vm.newObject();
|
||||
|
||||
const logHandle = vm.newFunction('log', (...args) => {
|
||||
const nativeArgs = args.map(vm.dump);
|
||||
console?.log && console.log(...nativeArgs);
|
||||
console?.log?.(...nativeArgs);
|
||||
});
|
||||
|
||||
const debugHandle = vm.newFunction('debug', (...args) => {
|
||||
const nativeArgs = args.map(vm.dump);
|
||||
console?.debug && console.debug(...nativeArgs);
|
||||
console?.debug?.(...nativeArgs);
|
||||
});
|
||||
|
||||
const infoHandle = vm.newFunction('info', (...args) => {
|
||||
const nativeArgs = args.map(vm.dump);
|
||||
console?.info && console.info(...nativeArgs);
|
||||
console?.info?.(...nativeArgs);
|
||||
});
|
||||
|
||||
const warnHandle = vm.newFunction('warn', (...args) => {
|
||||
const nativeArgs = args.map(vm.dump);
|
||||
console?.warn && console.warn(...nativeArgs);
|
||||
console?.warn?.(...nativeArgs);
|
||||
});
|
||||
|
||||
const errorHandle = vm.newFunction('error', (...args) => {
|
||||
const nativeArgs = args.map(vm.dump);
|
||||
console?.error && console.error(...nativeArgs);
|
||||
console?.error?.(...nativeArgs);
|
||||
});
|
||||
|
||||
vm.setProp(consoleHandle, 'log', logHandle);
|
||||
|
||||
Reference in New Issue
Block a user