mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-09-24 04:53:31 +08:00
新增 {{py}} 和 {{js}} 两个特殊变量
This commit is contained in:
@@ -4,7 +4,8 @@ const child_process = require("child_process")
|
||||
const iconv = require('iconv-lite')
|
||||
const electron = require('electron')
|
||||
const {
|
||||
NodeVM
|
||||
NodeVM,
|
||||
VM
|
||||
} = require('./lib/vm2')
|
||||
const path = require("path")
|
||||
const util = require("util")
|
||||
@@ -187,6 +188,18 @@ if (process.platform == 'win32') quickcommand.runVbs = function(script) {
|
||||
})
|
||||
}
|
||||
|
||||
// python -c
|
||||
runPythonCommand = py => {
|
||||
try {
|
||||
return child_process.execFileSync("python", ["-c", py], {
|
||||
windowsHide: true,
|
||||
})
|
||||
} catch (e) {
|
||||
utools.showNotification(e)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 在终端中执行
|
||||
if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline, dir) {
|
||||
@@ -347,6 +360,10 @@ let parseItem = item => {
|
||||
|
||||
let parseStdout = stdout => stdout.map(x => parseItem(x)).join("\n")
|
||||
|
||||
VmEval = (cmd, sandbox = {}) => new VM({
|
||||
sandbox: sandbox
|
||||
}).run(cmd)
|
||||
|
||||
// The vm module of Node.js is deprecated in the renderer process and will be removed
|
||||
runCodeInVm = (cmd, cb) => {
|
||||
const vm = createNodeVM()
|
||||
|
Reference in New Issue
Block a user