ogit
Version:
A lazy developer's Git CLI made simple. Makes using git on cloud IDEs (i.e. C9) a walk in the park.
56 lines (55 loc) • 2.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const AbstractStashCommand_1 = require("../abstracts/AbstractStashCommand");
const OperationUtils_1 = require("../utils/OperationUtils");
const git_1 = require("../wrapper/git");
class DeleteStashCommand extends AbstractStashCommand_1.default {
constructor() {
super(...arguments);
this.shouldProceedWithPrompts = () => {
if (this.stashNames.length === 0) {
console.log('You do not have any stashes to delete.');
return false;
}
return true;
};
}
getPrompts() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const verifyingNumber = OperationUtils_1.OperationUtils.getRandomVerificationNumber();
return [
{
message: 'Select the stash to delete',
type: 'list',
choices: this.stashNames,
name: 'selectedStash',
validate(choice) {
return !!choice;
}
},
{
message: `Please enter ${verifyingNumber} on the prompt`,
type: 'input',
name: 'verificationConfirmed',
validate(number) {
return number === verifyingNumber;
}
}
];
});
}
performStashOperation(answers) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const selectedStash = answers.selectedStash;
yield git_1.GitFacade.deleteStash(selectedStash.stashNumber, selectedStash.stashName);
});
}
run() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield this.runHelper();
});
}
}
DeleteStashCommand.description = 'Deletes a list of stashes in the repo';
exports.DeleteStashCommand = DeleteStashCommand;