UNPKG

ogit

Version:

A lazy developer's Git CLI made simple. Makes using git on cloud IDEs (i.e. C9) a walk in the park.

60 lines (59 loc) 2.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const AbstractStashCommand_1 = require("../abstracts/AbstractStashCommand"); const git_1 = require("../wrapper/git"); class UnStashCommand extends AbstractStashCommand_1.default { constructor() { super(...arguments); this.shouldProceedWithPrompts = () => { if (this.stashNames.length === 0) { console.log('You do not have any stashes to run this operation.'); return false; } return true; }; } getPrompts() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return [ { message: 'Select the stash to apply back', type: 'list', choices: this.stashNames, name: 'selectedStash', validate(choice) { return choice.length > 0; } }, { message: 'Remove stash after applying?', type: 'confirm', name: 'removeAfterApplying', default: true } ]; }); } performStashOperation(answers) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const selectedStash = answers.selectedStash; try { yield git_1.GitFacade.unstash(selectedStash.stashNumber, selectedStash.stashName, answers.removeAfterApplying); } catch (error) { console.log('Unstashing conflicts with the following files:'); for (let i = 0; i < error.fileNamesArray.length; i++) { console.log(error.fileNamesArray[i]); } } }); } run() { return tslib_1.__awaiter(this, void 0, void 0, function* () { yield this.runHelper(); }); } } UnStashCommand.description = 'Applies the stashed changes back into workspace'; exports.UnStashCommand = UnStashCommand;