mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
修复console.log 无法打印多个参数的 bug
This commit is contained in:
parent
e44f9d7fe7
commit
00e94588d5
@ -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 => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user