smartlog-destination-local/dist/beautylog.figlet.js
2017-03-11 12:30:18 +01:00

50 lines
4.0 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const plugins = require("./beautylog.plugins");
let defaultOptions = {
font: 'Star Wars',
color: 'green',
cb: function () { }
};
exports.figlet = function (textArg, optionsArg) {
let done = plugins.q.defer();
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
let options = plugins.lodash.assign(mergeOptions, optionsArg);
plugins.figlet(textArg, {
font: options.font,
horizontalLayout: 'default',
verticalLayout: 'default'
}, function (err, data) {
if (err) {
console.log('Something went wrong...');
console.dir(err);
return;
}
console.log(colorFiglet(data, options.color));
options.cb();
done.resolve();
});
return done.promise;
};
exports.figletSync = function (textArg, optionsArg) {
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
let options = plugins.lodash.assign(mergeOptions, optionsArg);
let figletString = plugins.figlet.textSync(textArg, {
font: options.font,
horizontalLayout: 'default',
verticalLayout: 'default'
});
console.log(colorFiglet(figletString, options.color));
return true;
};
let colorFiglet = (figletStringArg, colorArg) => {
let figletArray = figletStringArg.split('\n');
let figletStringCombined = '';
for (let figletRow of figletArray) {
figletRow = plugins.beautycolor.coloredString(figletRow, colorArg);
figletStringCombined = figletStringCombined + figletRow + '\n';
}
return figletStringCombined;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmZpZ2xldC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2JlYXV0eWxvZy5maWdsZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsK0NBQStDO0FBUS9DLElBQUksY0FBYyxHQUFtQjtJQUNqQyxJQUFJLEVBQUUsV0FBVztJQUNqQixLQUFLLEVBQUUsT0FBTztJQUNkLEVBQUUsRUFBRSxjQUFZLENBQUM7Q0FDcEIsQ0FBQ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