ogit
Version:
A lazy developer's Git CLI made simple. Makes using git on cloud IDEs (i.e. C9) a walk in the park.
54 lines (53 loc) • 2.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
require("reflect-metadata");
const command_1 = require("@oclif/command");
const inquirer = require("inquirer");
const models_1 = require("../models");
const git_1 = require("../wrapper/git");
const FileNameUtils_1 = require("../utils/FileNameUtils");
class default_1 extends command_1.Command {
constructor() {
super(...arguments);
this.choices = [];
this.getListOfFilesFromPrompt = (files) => {
const processedFileNames = [];
files.forEach(file => {
processedFileNames.push(file.path);
});
return processedFileNames;
};
}
runHelper() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let loopCondition = true;
while (loopCondition) {
const status = yield git_1.GitFacade.status();
if (status.all.length > 0) {
this.choices = [];
status.all.forEach(file => {
this.choices.push({
name: `${file.path} ${FileNameUtils_1.FileNameUtils.getFileChangeType(file.changeType)}`,
value: file,
checked: true
});
});
const answers = yield inquirer.prompt(yield this.getPrompts());
//lets filter out the files that needs to be added to git seperately..
answers.fileToBeCommitted.forEach((file) => tslib_1.__awaiter(this, void 0, void 0, function* () {
if (file.changeType === models_1.ChangeTypes.New) {
yield git_1.GitFacade.addToRepo(file.path);
}
}));
yield git_1.GitFacade.optimizeRepo();
yield this.runCommit(answers.commitMessage, this.getListOfFilesFromPrompt(answers.fileToBeCommitted), answers.skipValidation);
}
else {
loopCondition = false;
}
}
});
}
}
exports.default = default_1;