@tuzki/cli
Version:
🐇 lowcode-cli is an efficient cli tool for Rabbitpre plugin component secondary development. ❤️
66 lines (65 loc) • 1.82 kB
TypeScript
import shell, { ExecCallback } from 'shelljs';
export interface ExecCommandOption {
/** 需要执行的unix命令 */
cmd: string;
/** 是否异步(default: `false`) */
async?: boolean;
/** 是否静默执行(不输出结果到控制台, default: `true`) */
silent?: boolean;
/** 环境变量 */
env?: Record<string, string>;
/** 需要 cwd 之后执行 */
cwd?: 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;
/**
* 异步执行`unix`命令
*
* @export
* @param {(Omit<ExecCommandOption, 'async' | 'callback'>)} opts
* @return {*} {Promise<number>}
*/
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 命令
* @return {*} {boolean}
*/
export declare function isCommandExist(cmd: string): boolean;
/**
* cd 路径文件夹
*
* @export
* @param {string} targetDir 目标文件夹
*/
export declare function cdTargetDir(targetDir: string): void;
/**
* 清除 shell 输出的空格
*
* @export
* @param {string} [stdout=''] shell 输出
* @return {*} {string}
*/
export declare function removeStdoutSpace(stdout?: string): string;
export {};