68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
declare const TaskCommandType: readonly ["npm-install"];
|
|
type TaskCommand = {
|
|
key?: string;
|
|
/**
|
|
* 任务描述
|
|
*/
|
|
description?: string;
|
|
/**
|
|
* 命令, 执行的任务
|
|
*/
|
|
command: string;
|
|
type?: (typeof TaskCommandType)[number] | string;
|
|
/**
|
|
* 任务执行完成后,执行判断的命令
|
|
*/
|
|
after?: string;
|
|
/**
|
|
* 任务执行前,执行判断的命令
|
|
*/
|
|
before?: string;
|
|
/**
|
|
* 任务执行完成后, 检测输出的文本内容,如果有这个文本,表示任务执行成功
|
|
* 如果没有这个文本,表示任务执行失败
|
|
*/
|
|
afterCheck?: string;
|
|
/**
|
|
* 任务执行前, 检测输出的文本内容,如果有这个文本,表示任务已经安装
|
|
* 如果没有这个文本,表示任务没有安装
|
|
*/
|
|
beforeCheck?: string;
|
|
};
|
|
declare class TasksCommand {
|
|
tasks: Map<string, TaskCommand>;
|
|
constructor();
|
|
addTask(task: TaskCommand, run?: boolean): this;
|
|
getTask(name: string): TaskCommand;
|
|
runTask(name: string): {
|
|
task: TaskCommand;
|
|
code: number;
|
|
} | {
|
|
code: number;
|
|
message: string;
|
|
};
|
|
/**
|
|
* 检测是否需要继续执行。
|
|
* 1. res.code === 500 代表执行失败, 需要继续执行
|
|
* 2. res.code === 200 代表执行成功,但是需要检测输出内容
|
|
* 2.1 如果有 check 的内容,代表不需要继续执行
|
|
* 2.2 如果没有 check 的内容,代表需要继续执行
|
|
* @param res
|
|
* @param check
|
|
* @returns
|
|
*/
|
|
private checkForContainue;
|
|
runCommand(command: string): {
|
|
code: number;
|
|
data: string;
|
|
message?: undefined;
|
|
} | {
|
|
code: number;
|
|
data: string;
|
|
message: any;
|
|
};
|
|
}
|
|
|
|
export { TaskCommandType, TasksCommand };
|
|
export type { TaskCommand };
|