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