UNPKG

utools-utils

Version:
44 lines (41 loc) 1.47 kB
import { ExecOptions, SpawnOptionsWithoutStdio } from 'node:child_process'; interface CommandReturn { stdout: string; kill: () => boolean; } /** * 运行命令 * @param command 完整命令 * @param options 选项 */ declare function execCommand(command: string, options?: ExecOptions): Promise<CommandReturn>; /** * 运行命令 * @param command 命令名 * @param args 命令参数 * @param inputs 标准输入 * @param options 选项 */ declare function spawnCommand(command: string, args: string[], inputs?: string[], options?: SpawnOptionsWithoutStdio): Promise<CommandReturn>; /** * 执行 PowerShell 脚本 * @param script 脚本 */ declare function execPowerShell(script: string): Promise<CommandReturn>; /** * 执行 AppleScript 脚本 * @param script 脚本 */ declare function execAppleScript(script: string): Promise<CommandReturn>; /** * 执行 AppleScript 脚本 * @param script 脚本 */ declare function execAppleScriptSync(script: string): string; /** * 执行脚本,Windows 上为 PowerShell、macOS 上为 AppleScript,Linux 上为 Shell。在执行脚本之前会执行 `hideAndOutPlugin()` * @param script 脚本 * @param defaultShell 是否使用各系统默认 Shell 执行,默认为 `false` */ declare function execScript(script: string, defaultShell?: boolean): Promise<CommandReturn>; export { CommandReturn, execAppleScript, execAppleScriptSync, execCommand, execPowerShell, execScript, spawnCommand };