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