mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-09-23 20:44:42 +08:00
去掉调试时的 console 语句
This commit is contained in:
@@ -246,7 +246,6 @@ let getCommandToLaunchTerminal = (cmdline, dir) => {
|
||||
end tell'`;
|
||||
|
||||
}
|
||||
console.log(command);
|
||||
return command;
|
||||
}
|
||||
|
||||
@@ -402,7 +401,6 @@ window.getSelectFile = hwnd => {
|
||||
encoding: "utf8",
|
||||
windowsHide: true
|
||||
})
|
||||
console.log(result);
|
||||
return result ? result.trim() : ""
|
||||
}
|
||||
}
|
||||
@@ -474,7 +472,7 @@ window.runCodeInSandbox = (code, callback, addVars = {}) => {
|
||||
let sandbox = getSandboxFuns()
|
||||
sandbox.console = {
|
||||
log: (...stdout) => {
|
||||
console.log(stdout);
|
||||
console.log("Result:", stdout);
|
||||
callback(stdout, null)
|
||||
},
|
||||
error: (...stderr) => {
|
||||
@@ -526,7 +524,7 @@ window.runCodeFile = (cmd, option, terminal, callback) => {
|
||||
charset = option.charset,
|
||||
scptarg = option.scptarg || "";
|
||||
let script = getQuickcommandTempFile(ext, 'quickcommandTempScript')
|
||||
// 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题
|
||||
// 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题
|
||||
if (charset.scriptCode) cmd = iconv.encode(cmd.replace(/\n/g, '\r\n'), charset.scriptCode);
|
||||
fs.writeFileSync(script, cmd);
|
||||
// var argvs = [script]
|
||||
@@ -548,27 +546,27 @@ window.runCodeFile = (cmd, option, terminal, callback) => {
|
||||
// 在终端中输出
|
||||
if (terminal) cmdline = getCommandToLaunchTerminal(cmdline)
|
||||
child = child_process.spawn(cmdline, {
|
||||
encoding: 'buffer',
|
||||
shell: true
|
||||
})
|
||||
// var chunks = [],
|
||||
// err_chunks = [];
|
||||
console.log('running: ' + cmdline);
|
||||
encoding: 'buffer',
|
||||
shell: true
|
||||
})
|
||||
// var chunks = [],
|
||||
// err_chunks = [];
|
||||
console.log('Running: ' + cmdline);
|
||||
child.stdout.on('data', chunk => {
|
||||
if (charset.outputCode) chunk = iconv.decode(chunk, charset.outputCode)
|
||||
callback(chunk.toString(), null)
|
||||
// chunks.push(chunk)
|
||||
// chunks.push(chunk)
|
||||
})
|
||||
child.stderr.on('data', stderr => {
|
||||
if (charset.outputCode) stderr = iconv.decode(stderr, charset.outputCode)
|
||||
callback(null, stderr.toString())
|
||||
// err_chunks.push(err_chunk)
|
||||
})
|
||||
// child.on('close', code => {
|
||||
// let stdout = chunks.join("");
|
||||
// let stderr = err_chunks.join("");
|
||||
// callback(stdout, stderr)
|
||||
// })
|
||||
if (charset.outputCode) stderr = iconv.decode(stderr, charset.outputCode)
|
||||
callback(null, stderr.toString())
|
||||
// err_chunks.push(err_chunk)
|
||||
})
|
||||
// child.on('close', code => {
|
||||
// let stdout = chunks.join("");
|
||||
// let stderr = err_chunks.join("");
|
||||
// callback(stdout, stderr)
|
||||
// })
|
||||
return child
|
||||
}
|
||||
|
||||
@@ -606,7 +604,7 @@ window.quickcommandHttpServer = () => {
|
||||
req.on('end', () => {
|
||||
let parsedParams
|
||||
let params = data.join("").toString()
|
||||
// 先尝试作为 json 解析
|
||||
// 先尝试作为 json 解析
|
||||
try {
|
||||
parsedParams = JSON.parse(params)
|
||||
} catch (error) {
|
||||
@@ -620,7 +618,7 @@ window.quickcommandHttpServer = () => {
|
||||
})
|
||||
httpServer.listen(port, 'localhost');
|
||||
httpServer.on('error', err => {
|
||||
console.log(err)
|
||||
console.log('httpErr:', err)
|
||||
})
|
||||
}
|
||||
let stop = () => {
|
||||
|
Reference in New Issue
Block a user