jack-cli
Version:
Chop through that Git log wicked fast!
57 lines • 2.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var colors_1 = require("../util/colors");
var config_util_1 = require("../util/config-util");
var interface_elements_1 = require("./interface-elements");
var notificationContainer;
exports.getNotificationContainer = function () {
if (notificationContainer) {
return notificationContainer;
}
notificationContainer = interface_elements_1.getBoxElement({
border: {
type: 'line',
},
bottom: 1,
name: 'notificationContainer',
padding: {
left: 1,
right: 1,
},
right: 0,
shrink: true,
tags: true,
});
notificationContainer.hide();
return notificationContainer;
};
var appendNotification = function (colorFn, content) {
if (notificationContainer.content.length) {
var longestLineLength = content
.split('\n')
.reduce(function (acc, cur) { return (acc >= cur.length ? acc : cur.length); }, 0);
notificationContainer.pushLine('-'.repeat(Math.min(longestLineLength, notificationContainer.screen
.width)));
}
notificationContainer.pushLine(colorFn(content));
setTimeout(function () {
notificationContainer.shiftLine(content.split('\n').length + 1);
if (!notificationContainer.content.length) {
notificationContainer.hide();
}
notificationContainer.screen.render();
}, config_util_1.getNotificationTimeout());
notificationContainer.show();
notificationContainer.screen.render();
};
var notifyFn = function (colorFn) { return function (content) {
return appendNotification(colorFn, content);
}; };
exports.notifier = {
error: notifyFn(colors_1.colors.error),
info: notifyFn(colors_1.colors.info),
log: notifyFn(function (s) { return s; }),
success: notifyFn(colors_1.colors.success),
warn: notifyFn(colors_1.colors.warning),
};
//# sourceMappingURL=notification.js.map