UNPKG

vde-layout

Version:

Terminal multiplexer layout management tool for VDE (Vibe Coding Development Environment)

64 lines 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TmuxExecutor = void 0; const execa_1 = require("execa"); const errors_1 = require("../utils/errors"); const executor_1 = require("../executor"); class TmuxExecutor { executor; constructor(options = {}) { if (options.executor) { this.executor = options.executor; } else if (options.dryRun === true) { this.executor = new executor_1.DryRunExecutor({ verbose: options.verbose }); } else if (this.isTestEnvironment()) { this.executor = new executor_1.MockExecutor(); } else { this.executor = new executor_1.RealExecutor({ verbose: options.verbose }); } } isTestEnvironment() { return process.env.VDE_TEST_MODE === "true" || process.env.NODE_ENV === "test" || process.env.VITEST === "true"; } 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", }); } if (this.executor.isDryRun()) { return; } try { await (0, execa_1.execa)("tmux", ["-V"]); } catch (_error) { throw new errors_1.EnvironmentError("tmux is not installed", errors_1.ErrorCodes.TMUX_NOT_FOUND, { hint: "Please install tmux", }); } } async execute(commandOrArgs) { return this.executor.execute(commandOrArgs); } async executeMany(commandsList) { return this.executor.executeMany(commandsList); } getCommandString(args) { return ["tmux", ...args].join(" "); } async getCurrentSessionName() { return this.execute(["display-message", "-p", "#{session_name}"]); } getExecutor() { return this.executor; } } exports.TmuxExecutor = TmuxExecutor; //# sourceMappingURL=executor.js.map