smartlog-destination-local/dist/beautylog.figlet.js
2016-05-14 01:18:44 +02:00

41 lines
4.8 KiB
JavaScript

"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./beautylog.plugins");
var defaultOptions = {
font: "Star Wars",
color: "green",
cb: function () { }
};
exports.figlet = function (textArg, optionsArg) {
var done = plugins.q.defer();
var mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
var 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(data[options.color]);
options.cb();
done.resolve();
});
return done.promise;
};
exports.figletSync = function (textArg, optionsArg) {
var mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
var options = plugins.lodash.assign(mergeOptions, optionsArg);
console.log(plugins.figlet.textSync(textArg, {
font: options.font,
horizontalLayout: 'default',
verticalLayout: 'default'
})[options.color]);
return true;
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJlYXV0eWxvZy5maWdsZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxxQkFBcUIsQ0FBQyxDQUFDO0FBQ2hELElBQUksY0FBYyxHQUFHO0lBQ2pCLElBQUksRUFBQyxXQUFXO0lBQ2hCLEtBQUssRUFBRSxPQUFPO0lBQ2QsRUFBRSxFQUFFLGNBQVcsQ0FBQztDQUNuQixDQUFDO0FBRVMsY0FBTSxHQUFHLFVBQVMsT0FBYyxFQUFDLFVBQVc7SUFDbkQsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixJQUFJLFlBQVksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxjQUFjLENBQUMsQ0F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