vde-layout
Version:
Terminal multiplexer layout management tool for VDE (Vibe Coding Development Environment)
73 lines • 2.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MockExecutor = void 0;
const errors_1 = require("../utils/errors");
class MockExecutor {
mockPaneCounter = 0;
mockPaneIds = ["%0"];
executedCommands = [];
async execute(commandOrArgs) {
const args = this.parseCommand(commandOrArgs);
this.executedCommands.push(args);
if (args.includes("display-message") && args.includes("#{pane_id}")) {
return this.mockPaneIds[0] ?? "%0";
}
if (args.includes("list-panes") && args.includes("#{pane_id}")) {
return this.mockPaneIds.join("\n");
}
if (args.includes("split-window")) {
this.mockPaneCounter++;
const newPaneId = `%${this.mockPaneCounter}`;
this.mockPaneIds.push(newPaneId);
}
return "";
}
async executeMany(commandsList) {
for (const args of commandsList) {
await this.execute(args);
}
}
isDryRun() {
return true;
}
logCommand(_command) {
}
getExecutedCommands() {
return this.executedCommands;
}
clearExecutedCommands() {
this.executedCommands = [];
}
setMockPaneIds(paneIds) {
this.mockPaneIds = paneIds;
}
getPaneIds() {
return this.mockPaneIds;
}
parseCommand(commandOrArgs) {
return typeof commandOrArgs === "string"
? commandOrArgs
.split(" ")
.filter((s) => s.length > 0)
.slice(1)
: commandOrArgs;
}
isInTmuxSession() {
return Boolean(process.env.TMUX);
}
async verifyTmuxEnvironment() {
if (!this.isInTmuxSession()) {
throw new errors_1.EnvironmentError("Must be run inside a tmux session", errors_1.ErrorCodes.NOT_IN_TMUX, {
hint: "Please start a tmux session and try again",
});
}
}
getCommandString(args) {
return ["tmux", ...args].join(" ");
}
async getCurrentSessionName() {
return "mock-session";
}
}
exports.MockExecutor = MockExecutor;
//# sourceMappingURL=mock-executor.js.map