49 lines
4.0 KiB
JavaScript
49 lines
4.0 KiB
JavaScript
"use strict";
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmZpZ2xldC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2JlYXV0eWxvZy5maWdsZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtB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