MCPcopy Index your code
hub / github.com/ZToolsCenter/ZTools / execute

Method execute

src/main/utils/appleScriptHelper.ts:16–26  ·  view source on GitHub ↗

* 执行 AppleScript 脚本 * @param script AppleScript 脚本内容 * @returns 脚本执行结果

(script: string)

Source from the content-addressed store, hash-verified

14 * @returns 脚本执行结果
15 */
16 private async execute(script: string): Promise<string> {
17 try {
18 // 转义单引号以防止脚本注入
19 const escapedScript = script.replace(/'/g, "'\\''")
20 const { stdout } = await execAsync(`osascript -e '${escapedScript}'`)
21 return stdout.trim()
22 } catch (error) {
23 console.error('[AppleScript] 执行 AppleScript 失败:', error)
24 throw error
25 }
26 }
27
28 /**
29 * 获取访达(Finder)当前打开的路径

Callers 13

getFinderPathMethod · 0.95
getFrontmostAppMethod · 0.95
getFrontmostAppNameMethod · 0.95
activateAppByNameMethod · 0.95
activateAppByBundleIdMethod · 0.95
activateAppByPathMethod · 0.95
openInTerminalMethod · 0.95
showNotificationMethod · 0.95
getRunningAppsMethod · 0.95
isAppRunningMethod · 0.95
quitAppMethod · 0.95
hideAppMethod · 0.95

Calls 1

execAsyncFunction · 0.85

Tested by

no test coverage detected