now has sync and async functions for figlet
This commit is contained in:
parent
1691b89fcf
commit
cdbc6a4e7f
3
index.d.ts
vendored
3
index.d.ts
vendored
@ -27,7 +27,8 @@ declare module BeautylogNodeTable {
|
||||
function init(): any;
|
||||
}
|
||||
declare module BeautylogNodeFiglet {
|
||||
var init: () => (textArg: string, optionsArg?: any) => void;
|
||||
var figlet: (textArg: string, optionsArg?: any) => any;
|
||||
var figletSync: (textArg: string, optionsArg?: any) => boolean;
|
||||
}
|
||||
declare module BeautylogBrowser {
|
||||
function init(): any;
|
||||
|
34
index.js
34
index.js
@ -76,7 +76,8 @@ var BeautylogNode;
|
||||
var beautylogNode = {
|
||||
log: BeautylogNodeLog.init(),
|
||||
code: BeautylogNodeCode.init(),
|
||||
figlet: BeautylogNodeFiglet.init()
|
||||
figlet: BeautylogNodeFiglet.figlet,
|
||||
figletSync: BeautylogNodeFiglet.figletSync
|
||||
};
|
||||
/**
|
||||
* logs an directory to console
|
||||
@ -232,13 +233,15 @@ var BeautylogNodeTable;
|
||||
/// <reference path="./index.ts" />
|
||||
var BeautylogNodeFiglet;
|
||||
(function (BeautylogNodeFiglet) {
|
||||
var figlet = function (textArg, optionsArg) {
|
||||
var defaultOptions = {
|
||||
font: "Star Wars",
|
||||
color: "green",
|
||||
cb: function () { }
|
||||
};
|
||||
var options = plugins.lodash.assign(defaultOptions, optionsArg);
|
||||
var defaultOptions = {
|
||||
font: "Star Wars",
|
||||
color: "green",
|
||||
cb: function () { }
|
||||
};
|
||||
BeautylogNodeFiglet.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',
|
||||
@ -251,12 +254,19 @@ var BeautylogNodeFiglet;
|
||||
}
|
||||
console.log(data[options.color]);
|
||||
options.cb();
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
BeautylogNodeFiglet.init = function () {
|
||||
var done = plugins.q.defer();
|
||||
done.resolve();
|
||||
return figlet;
|
||||
BeautylogNodeFiglet.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;
|
||||
};
|
||||
})(BeautylogNodeFiglet || (BeautylogNodeFiglet = {}));
|
||||
/// <reference path="./index.ts" />
|
||||
|
@ -64,8 +64,12 @@ describe("beautylog", function () {
|
||||
});
|
||||
describe(".figlet", function () {
|
||||
it("should print nice fonts to console in yellow", function (done) {
|
||||
this.timeout(10000);
|
||||
beautylog.figlet("Awesome!", { font: "Star Wars", color: "yellow", cb: done });
|
||||
beautylog.figlet("Async!", { font: "Star Wars", color: "yellow" }).then(done);
|
||||
});
|
||||
});
|
||||
describe(".figletSync", function () {
|
||||
it("should print nice fonts to console in yellow", function () {
|
||||
beautylog.figletSync("Sync!", { font: "Star Wars", color: "blue" });
|
||||
});
|
||||
});
|
||||
describe(".code", function () {
|
||||
|
@ -1,12 +1,14 @@
|
||||
/// <reference path="./index.ts" />
|
||||
module BeautylogNodeFiglet {
|
||||
var figlet = function(textArg:string,optionsArg?){
|
||||
var defaultOptions = {
|
||||
font:"Star Wars",
|
||||
color: "green",
|
||||
cb: function(){}
|
||||
};
|
||||
var options = plugins.lodash.assign(defaultOptions,optionsArg);
|
||||
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);
|
||||
plugins.figlet(textArg,{
|
||||
font: options.font,
|
||||
horizontalLayout: 'default',
|
||||
@ -19,11 +21,18 @@ module BeautylogNodeFiglet {
|
||||
}
|
||||
console.log(data[options.color]);
|
||||
options.cb();
|
||||
done.resolve();
|
||||
});
|
||||
}
|
||||
export var init = function(){
|
||||
var done = plugins.q.defer();
|
||||
done.resolve();
|
||||
return figlet;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ module BeautylogNode {
|
||||
var beautylogNode:any = {
|
||||
log:BeautylogNodeLog.init(),
|
||||
code:BeautylogNodeCode.init(),
|
||||
figlet:BeautylogNodeFiglet.init()
|
||||
figlet:BeautylogNodeFiglet.figlet,
|
||||
figletSync:BeautylogNodeFiglet.figletSync
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -64,8 +64,12 @@ describe("beautylog",function(){
|
||||
});
|
||||
describe(".figlet",function(){
|
||||
it("should print nice fonts to console in yellow",function(done){
|
||||
this.timeout(10000);
|
||||
beautylog.figlet("Awesome!",{font:"Star Wars",color:"yellow",cb:done});
|
||||
beautylog.figlet("Async!",{font:"Star Wars",color:"yellow"}).then(done);
|
||||
})
|
||||
});
|
||||
describe(".figletSync",function(){
|
||||
it("should print nice fonts to console in yellow",function(){
|
||||
beautylog.figletSync("Sync!",{font:"Star Wars",color:"blue"});
|
||||
})
|
||||
});
|
||||
describe(".code",function(){
|
||||
|
Loading…
Reference in New Issue
Block a user