修复console.log 无法打印多个参数的 bug

This commit is contained in:
fofolee 2022-04-10 10:00:25 +08:00
parent e44f9d7fe7
commit 00e94588d5

View File

@ -345,13 +345,15 @@ let parseItem = item => {
return item.toString() return item.toString()
} }
let parseStdout = stdout => stdout.map(x => parseItem(x)).join("\n")
// The vm module of Node.js is deprecated in the renderer process and will be removed // The vm module of Node.js is deprecated in the renderer process and will be removed
runCodeInVm = (cmd, cb) => { runCodeInVm = (cmd, cb) => {
const vm = createNodeVM() const vm = createNodeVM()
//重定向 console //重定向 console
vm.on('console.log', stdout => { vm.on('console.log', (...stdout) => {
console.log(stdout); console.log(stdout);
cb(parseItem(stdout), null) cb(parseStdout(stdout), null)
}); });
vm.on('console.error', stderr => { vm.on('console.error', stderr => {