40 lines
4.7 KiB
JavaScript
40 lines
4.7 KiB
JavaScript
|
/// <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;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJlYXV0eWxvZy5ub2RlLmZpZ2xldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSw0Q0FBNEM7QUFDNUMsSUFBTyxPQUFPLFdBQVcscUJBQXFCLENBQUMsQ0FBQztBQUNoRCxJQUFJLGNBQWMsR0FBRztJQUNqQixJQUFJLEVBQUMsV0FBVztJQUNoQixLQUFLLEVBQUUsT0FBTztJQUNkLEVBQUUsRUFBRSxjQUFXLENBQUM7Q0FDbkIsQ0FBQztBQUNT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