Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit bfd7ef4

Browse files
authored
Merge pull request #57 from Bluemangoo/945
Feat: enable multi-command stop command
2 parents 7b2e368 + 5a7fb35 commit bfd7ef4

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/entity/commands/general/general_stop.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ export default class GeneralStopCommand extends InstanceCommand {
1616

1717
instance.status(Instance.STATUS_STOPPING);
1818

19-
if (stopCommand.toLocaleLowerCase() == "^c") {
20-
instance.process.kill("SIGINT");
21-
} else {
22-
await instance.exec(new SendCommand(stopCommand));
19+
const stopCommandList = stopCommand.split("\n");
20+
for (const stopCommandColumn of stopCommandList) {
21+
if (stopCommandColumn.toLocaleLowerCase() == "^c") {
22+
instance.process.kill("SIGINT");
23+
} else {
24+
await instance.exec(new SendCommand(stopCommandColumn));
25+
}
2326
}
2427

2528
instance.println("INFO", $t("general_stop.execCmd", { stopCommand }));

src/entity/commands/pty/pty_stop.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ export default class PtyStopCommand extends InstanceCommand {
1717
instance.status(Instance.STATUS_STOPPING);
1818

1919
instance.println("INFO", $t("pty_stop.execCmd", { stopCommand: stopCommand }));
20-
if (stopCommand.toLowerCase() == "^c") stopCommand = "\x03";
21-
await instance.exec(new SendCommand(stopCommand));
20+
21+
const stopCommandList = stopCommand.split("\n");
22+
for (const stopCommandColumn of stopCommandList) {
23+
if (stopCommandColumn.toLocaleLowerCase() == "^c") {
24+
await instance.exec(new SendCommand("\x03"));
25+
} else {
26+
await instance.exec(new SendCommand(stopCommandColumn));
27+
}
28+
}
2229

2330
// If the instance is still in the stopped state after 10 minutes, restore the state
2431
const cacheStartCount = instance.startCount;

0 commit comments

Comments
 (0)