decova-gotcha
Version:
It's my personal trial for automating daunting tasks
44 lines • 2.66 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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LTool_AbstractEditAugmenterFile = void 0;
const TerminalAgent_1 = require("../external-sheet/TerminalAgent");
const GotchaRepo_1 = require("./Techies/ArtifactMan/GotchaRepo");
const LocalToolsDispatcher_1 = require("./LocalToolsDispatcher");
const LTool_CheckGotchaLocalRepo_1 = require("./LTool_CheckGotchaLocalRepo");
const PathMan_1 = require("./Techies/PathMan");
const os_1 = __importDefault(require("os"));
const tsyringe_1 = require("tsyringe");
class LTool_AbstractEditAugmenterFile {
constructor() {
this.srv_PathMan = tsyringe_1.container.resolve(PathMan_1.PathMan);
this.srv_GotchaRepo = tsyringe_1.container.resolve(GotchaRepo_1.GotchaRepo);
}
TakeControlAsync(args) {
return __awaiter(this, void 0, void 0, function* () {
const file = this.srv_PathMan.GotchaLocalRepo_WalkthroughsSheet;
while (file.Exists() == false) {
TerminalAgent_1.TerminalAgent.ShowError(`File [${file.FullName}] doesn't exist. I'll try to check out the repo.`);
yield LocalToolsDispatcher_1.LocalToolsDispatcher.RunAsync(new LTool_CheckGotchaLocalRepo_1.LTool_CheckOutGotchaLocalRepo());
}
const cmd = os_1.default.platform() == "win32" ? `code ${this.FilePath}`
: `sudo code --user-data-dir="~/.vscode-root" ${this.FilePath}`;
TerminalAgent_1.TerminalAgent.Hint(this.GetHint());
yield TerminalAgent_1.TerminalAgent.AskToRunCommandAsync(cmd);
yield this.srv_GotchaRepo.PromptThenCommitAndPushAsync();
});
}
}
exports.LTool_AbstractEditAugmenterFile = LTool_AbstractEditAugmenterFile;
//# sourceMappingURL=LTool_AbstractEditAugmenterFile.js.map