@eightshone/sshman
Version:
A simple cli ssh manager
33 lines • 1.64 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import updateConfigs from "../../utils/updateConfigs.js";
import init from "../functions/init.js";
import sshConnection from "../functions/ssh.js";
function reconnectCommand() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
// intialize the cli app
let { config, logs } = yield init();
// exit if there are no recent servers
if (!config.recentServers.length) {
console.log("❌ There are no recent sessions");
return;
}
// get last config
const connectTo = config.recentServers[0];
console.log(`🔄 Reconnecting to "${(_a = connectTo.name) !== null && _a !== void 0 ? _a : connectTo.username + "@" + connectTo.host}"`);
// update logs
yield updateConfigs(config, logs, connectTo, false);
// connect
sshConnection(connectTo);
});
}
export default reconnectCommand;
//# sourceMappingURL=reconnect.js.map