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

39 lines
1.3 KiB
TypeScript
Raw Normal View History

2016-02-11 03:04:49 +00:00
/// <reference path="./index.ts" />
module BeautylogNodeFiglet {
var defaultOptions = {
font:"Star Wars",
color: "green",
cb: function(){}
};
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);
2016-02-11 03:04:49 +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;
}
console.log(data[options.color]);
options.cb();
done.resolve();
2016-02-11 03:04:49 +00:00
});
return done.promise;
};
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;
2016-02-11 03:04:49 +00:00
};
}