@szzbmy/lowcode-cli
Version:
🐇 lowcode-cli is an efficient cli tool for Rabbitpre plugin component secondary development. ❤️
46 lines (45 loc) • 1.33 kB
TypeScript
/**
* shelljs模块相关辅助函数
* @author VenDream
* @since 2021-1-11
*/
import shell, { ExecCallback } from 'shelljs';
interface ExecCommandOption {
/** 需要执行的unix命令 */
cmd: string;
/** 是否异步(default: `false`) */
async?: boolean;
/** 是否静默执行(不输出结果到控制台, default: `true`) */
silent?: boolean;
/** 环境变量 */
env?: Record<string, string>;
/** 命令执行回调,仅当`async`设置为`true`时有效 */
callback?: ExecCallback;
}
interface BatchExecCommandOption extends Omit<ExecCommandOption, 'cmd'> {
/** 需要执行的unix命令集 */
cmds: string[];
}
/**
* 执行单个`unix`命令
*
* @export
* @param {ExecCommandOption} opts 执行选项
*/
export declare function execCommand(opts: ExecCommandOption): shell.ShellString | null;
export declare function execCommandPromise(opts: Omit<ExecCommandOption, 'async' | 'callback'>): Promise<number>;
/**
* 批量执行`unix`命令
*
* @export
* @param {BatchExecCommandOption} opts 执行选项
*/
export declare function batchExecCommand(opts: BatchExecCommandOption): void;
/**
* 检查当前环境变量中是否存在指定命令
*
* @export
* @param {string} cmd 命令
*/
export declare function isCommandExist(cmd: string): boolean;
export {};