Feat: docker empty command start method

This commit is contained in:
unitwk 2023-01-15 14:25:32 +08:00
parent 8ea9dfc304
commit 32cdbace6c
4 changed files with 11 additions and 4 deletions

View File

@ -48,7 +48,7 @@ export function commandStringToArray(cmd: string) {
_analyze();
if (cmdArray.length == 0) {
throw new Error($t("command.errLen"));
return [];
}
for (const index in cmdArray) {

View File

@ -92,7 +92,7 @@ export default class DockerStartCommand extends InstanceCommand {
}
async exec(instance: Instance, source = "Unknown") {
if (!instance.config.startCommand || !instance.config.cwd || !instance.config.ie || !instance.config.oe)
if (!instance.config.cwd || !instance.config.ie || !instance.config.oe)
return instance.failure(new StartupDockerProcessError($t("instance.dirEmpty")));
if (!fs.existsSync(instance.absoluteCwdPath())) return instance.failure(new StartupDockerProcessError($t("instance.dirNoE")));

View File

@ -62,7 +62,12 @@ export default class GeneralStartCommand extends InstanceCommand {
}
async exec(instance: Instance, source = "Unknown") {
if (!instance.config.startCommand || !instance.config.cwd || !instance.config.ie || !instance.config.oe)
if (
(!instance.config.startCommand && instance.config.processType === "general") ||
!instance.config.cwd ||
!instance.config.ie ||
!instance.config.oe
)
return instance.failure(new StartupError($t("general_start.instanceConfigErr")));
if (!fs.existsSync(instance.absoluteCwdPath())) return instance.failure(new StartupError($t("general_start.cwdPathNotExist")));

View File

@ -8,6 +8,8 @@ interface IActionCommand {
command: string;
}
type ProcessType = "general" | "docker";
// @Entity
export default class InstanceConfig {
public nickname = "Undefined";
@ -22,7 +24,7 @@ export default class InstanceConfig {
public tag: string[] = [];
public endTime: string = "";
public fileCode: string = "utf-8";
public processType: string = "general";
public processType: ProcessType = "general";
public updateCommand: string = "";
public crlf = os.platform() === "win32" ? 2 : 1; // 1: \n 2: \r\n