smartlog-destination-local/dist/beautylog.figlet.js

50 lines
4.1 KiB
JavaScript
Raw Normal View History

2016-05-02 00:23:40 +00:00
"use strict";
2017-03-11 11:30:18 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
2016-05-23 07:10:30 +00:00
require("typings-global");
2016-07-23 17:47:23 +00:00
const plugins = require("./beautylog.plugins");
2016-10-16 00:26:43 +00:00
let defaultOptions = {
font: 'Star Wars',
color: 'green',
2016-05-02 00:23:40 +00:00
cb: function () { }
};
exports.figlet = function (textArg, optionsArg) {
2016-10-16 00:26:43 +00:00
let done = plugins.q.defer();
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
let options = plugins.lodash.assign(mergeOptions, optionsArg);
2016-05-02 00:23:40 +00:00
plugins.figlet(textArg, {
font: options.font,
horizontalLayout: 'default',
verticalLayout: 'default'
}, function (err, data) {
if (err) {
console.log('Something went wrong...');
console.dir(err);
return;
}
2017-01-21 18:33:14 +00:00
console.log(colorFiglet(data, options.color));
2016-05-02 00:23:40 +00:00
options.cb();
done.resolve();
});
return done.promise;
};
exports.figletSync = function (textArg, optionsArg) {
2016-10-16 00:26:43 +00:00
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
let options = plugins.lodash.assign(mergeOptions, optionsArg);
2017-01-21 18:04:40 +00:00
let figletString = plugins.figlet.textSync(textArg, {
2016-05-02 00:23:40 +00:00
font: options.font,
horizontalLayout: 'default',
verticalLayout: 'default'
2017-01-21 18:04:40 +00:00
});
2017-01-21 18:33:14 +00:00
console.log(colorFiglet(figletString, options.color));
2016-05-02 00:23:40 +00:00
return true;
};
2017-01-21 18:04:40 +00:00
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;
};
2018-03-01 00:06:12 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2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