smartlog-destination-local/dist/beautylog.figlet.js
2016-05-02 02:23:40 +02:00

41 lines
4.7 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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