smartlog-destination-local/ts/beautylog.figlet.ts

40 lines
1.2 KiB
TypeScript
Raw Normal View History

2016-05-23 07:10:30 +00:00
import "typings-global";
2016-02-23 13:34:40 +00:00
import plugins = require("./beautylog.plugins");
var defaultOptions = {
font:"Star Wars",
color: "green",
cb: function(){}
};
2016-05-02 00:23:40 +00:00
2016-02-23 13:34:40 +00:00
export var figlet = function(textArg:string,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;
};
2016-05-02 00:23:40 +00:00
2016-02-23 13:34:40 +00:00
export var figletSync = function(textArg:string,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;
};