added figlet
This commit is contained in:
parent
5c52e6f9ed
commit
aa4f3d980a
@ -6,6 +6,7 @@ beautiful logging
|
|||||||
[![Dependency Status](https://david-dm.org/pushrocks/beautylog.svg)](https://david-dm.org/pushrocks/beautylog)
|
[![Dependency Status](https://david-dm.org/pushrocks/beautylog.svg)](https://david-dm.org/pushrocks/beautylog)
|
||||||
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/beautylog/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/beautylog/master/dependencies/npm)
|
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/beautylog/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/beautylog/master/dependencies/npm)
|
||||||
[![bitHound Score](https://www.bithound.io/github/pushrocks/beautylog/badges/score.svg)](https://www.bithound.io/github/pushrocks/beautylog)
|
[![bitHound Score](https://www.bithound.io/github/pushrocks/beautylog/badges/score.svg)](https://www.bithound.io/github/pushrocks/beautylog)
|
||||||
|
[![Coverage Status](https://coveralls.io/repos/github/pushrocks/beautylog/badge.svg?branch=greenkeeper-npmts-2.1.10)](https://coveralls.io/github/pushrocks/beautylog?branch=greenkeeper-npmts-2.1.10)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
```javascript
|
```javascript
|
||||||
|
5
index.d.ts
vendored
5
index.d.ts
vendored
@ -26,8 +26,13 @@ declare module BeautylogNodeTable {
|
|||||||
var cliTable: any;
|
var cliTable: any;
|
||||||
function init(): any;
|
function init(): any;
|
||||||
}
|
}
|
||||||
|
declare module BeautylogNodeFiglet {
|
||||||
|
var init: () => (textArg: string, optionsArg?: any) => void;
|
||||||
|
}
|
||||||
declare module BeautylogBrowser {
|
declare module BeautylogBrowser {
|
||||||
function init(): any;
|
function init(): any;
|
||||||
}
|
}
|
||||||
|
declare module BeautylogPromiseChain {
|
||||||
|
}
|
||||||
declare var plugins: any;
|
declare var plugins: any;
|
||||||
declare var beautylog: any;
|
declare var beautylog: any;
|
||||||
|
54
index.js
54
index.js
@ -3,10 +3,20 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./index.ts" />
|
||||||
var BeautylogPlugins;
|
var BeautylogPlugins;
|
||||||
(function (BeautylogPlugins) {
|
(function (BeautylogPlugins) {
|
||||||
|
var plugins = {};
|
||||||
BeautylogPlugins.init = function () {
|
BeautylogPlugins.init = function () {
|
||||||
var plugins = {
|
plugins = {
|
||||||
smartenv: require("smartenv")
|
lodash: require("lodash"),
|
||||||
|
smartenv: require("smartenv"),
|
||||||
|
q: require("q")
|
||||||
};
|
};
|
||||||
|
if (plugins.smartenv.getEnv().isNode) {
|
||||||
|
plugins = plugins.lodash.assign(plugins, {
|
||||||
|
colors: require("colors"),
|
||||||
|
clc: require("cli-color"),
|
||||||
|
figlet: require("figlet")
|
||||||
|
});
|
||||||
|
}
|
||||||
return plugins;
|
return plugins;
|
||||||
};
|
};
|
||||||
})(BeautylogPlugins || (BeautylogPlugins = {}));
|
})(BeautylogPlugins || (BeautylogPlugins = {}));
|
||||||
@ -63,12 +73,11 @@ var ConsoleTable = (function () {
|
|||||||
var BeautylogNode;
|
var BeautylogNode;
|
||||||
(function (BeautylogNode) {
|
(function (BeautylogNode) {
|
||||||
function init() {
|
function init() {
|
||||||
plugins.colors = require("colors");
|
|
||||||
plugins.clc = require("cli-color");
|
|
||||||
var beautylogNode = {
|
var beautylogNode = {
|
||||||
log: BeautylogNodeLog.init(),
|
log: BeautylogNodeLog.init(),
|
||||||
code: BeautylogNodeCode.init()
|
code: BeautylogNodeCode.init(),
|
||||||
}; //object to append to all public facing functions
|
figlet: BeautylogNodeFiglet.init()
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* logs an directory to console
|
* logs an directory to console
|
||||||
* @param logText
|
* @param logText
|
||||||
@ -221,6 +230,36 @@ var BeautylogNodeTable;
|
|||||||
BeautylogNodeTable.init = init;
|
BeautylogNodeTable.init = init;
|
||||||
})(BeautylogNodeTable || (BeautylogNodeTable = {}));
|
})(BeautylogNodeTable || (BeautylogNodeTable = {}));
|
||||||
/// <reference path="./index.ts" />
|
/// <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);
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
BeautylogNodeFiglet.init = function () {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
done.resolve();
|
||||||
|
return figlet;
|
||||||
|
};
|
||||||
|
})(BeautylogNodeFiglet || (BeautylogNodeFiglet = {}));
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
var BeautylogBrowser;
|
var BeautylogBrowser;
|
||||||
(function (BeautylogBrowser) {
|
(function (BeautylogBrowser) {
|
||||||
function init() {
|
function init() {
|
||||||
@ -244,6 +283,7 @@ var BeautylogBrowser;
|
|||||||
}
|
}
|
||||||
BeautylogBrowser.init = init;
|
BeautylogBrowser.init = init;
|
||||||
})(BeautylogBrowser || (BeautylogBrowser = {}));
|
})(BeautylogBrowser || (BeautylogBrowser = {}));
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
/// <reference path="./beautylog.plugins.ts" />
|
/// <reference path="./beautylog.plugins.ts" />
|
||||||
/// <reference path="./beautylog.classes.ts" />
|
/// <reference path="./beautylog.classes.ts" />
|
||||||
@ -251,7 +291,9 @@ var BeautylogBrowser;
|
|||||||
/// <reference path="./beautylog.node.log.ts" />
|
/// <reference path="./beautylog.node.log.ts" />
|
||||||
/// <reference path="./beautylog.node.code.ts" />
|
/// <reference path="./beautylog.node.code.ts" />
|
||||||
/// <reference path="./beautylog.node.table.ts" />
|
/// <reference path="./beautylog.node.table.ts" />
|
||||||
|
/// <reference path="./beautylog.node.figlet.ts" />
|
||||||
/// <reference path="./beautylog.browser.ts" />
|
/// <reference path="./beautylog.browser.ts" />
|
||||||
|
/// <reference path="./beautylog.promisechain.ts" />
|
||||||
var plugins = BeautylogPlugins.init();
|
var plugins = BeautylogPlugins.init();
|
||||||
var beautylog = (function () {
|
var beautylog = (function () {
|
||||||
switch (plugins.smartenv.getEnv().runtimeEnv) {
|
switch (plugins.smartenv.getEnv().runtimeEnv) {
|
||||||
|
@ -33,7 +33,10 @@
|
|||||||
"cli-color": "^1.1.0",
|
"cli-color": "^1.1.0",
|
||||||
"cli-table2": "^0.2.0",
|
"cli-table2": "^0.2.0",
|
||||||
"colors": "1.1.2",
|
"colors": "1.1.2",
|
||||||
|
"figlet": "^1.1.1",
|
||||||
"hlight": "0.0.7",
|
"hlight": "0.0.7",
|
||||||
|
"lodash": "^4.3.0",
|
||||||
|
"q": "^1.4.1",
|
||||||
"smartenv": "0.0.15"
|
"smartenv": "0.0.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -24,7 +24,7 @@ describe("beautylog", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe(".error(message)", function () {
|
describe(".error(message)", function () {
|
||||||
it("sould print a red error message", function () {
|
it("should print a red error message", function () {
|
||||||
beautylog.error('beautylog.error(), with normal logText, without logType');
|
beautylog.error('beautylog.error(), with normal logText, without logType');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -62,6 +62,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 });
|
||||||
|
});
|
||||||
|
});
|
||||||
describe(".code", function () {
|
describe(".code", function () {
|
||||||
it("should highlight code", function () {
|
it("should highlight code", function () {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
|
29
ts/beautylog.node.figlet.ts
Normal file
29
ts/beautylog.node.figlet.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/// <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);
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export var init = function(){
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
done.resolve();
|
||||||
|
return figlet;
|
||||||
|
};
|
||||||
|
}
|
@ -1,13 +1,12 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./index.ts" />
|
||||||
module BeautylogNode {
|
module BeautylogNode {
|
||||||
export function init() {
|
export function init() {
|
||||||
plugins.colors = require("colors");
|
|
||||||
plugins.clc = require("cli-color");
|
|
||||||
|
|
||||||
var beautylogNode:any = {
|
var beautylogNode:any = {
|
||||||
log:BeautylogNodeLog.init(),
|
log:BeautylogNodeLog.init(),
|
||||||
code:BeautylogNodeCode.init()
|
code:BeautylogNodeCode.init(),
|
||||||
}; //object to append to all public facing functions
|
figlet:BeautylogNodeFiglet.init()
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logs an directory to console
|
* logs an directory to console
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./index.ts" />
|
||||||
module BeautylogPlugins {
|
module BeautylogPlugins {
|
||||||
|
var plugins:any = {};
|
||||||
export var init = function(){
|
export var init = function(){
|
||||||
var plugins:any = {
|
plugins = {
|
||||||
smartenv: require("smartenv")
|
lodash: require("lodash"),
|
||||||
|
smartenv: require("smartenv"),
|
||||||
|
q: require("q")
|
||||||
};
|
};
|
||||||
|
if (plugins.smartenv.getEnv().isNode){
|
||||||
|
plugins = plugins.lodash.assign(plugins,{
|
||||||
|
colors: require("colors"),
|
||||||
|
clc: require("cli-color"),
|
||||||
|
figlet: require("figlet")
|
||||||
|
});
|
||||||
|
}
|
||||||
return plugins;
|
return plugins;
|
||||||
};
|
};
|
||||||
}
|
}
|
4
ts/beautylog.promisechain.ts
Normal file
4
ts/beautylog.promisechain.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module BeautylogPromiseChain {
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,9 @@
|
|||||||
/// <reference path="./beautylog.node.log.ts" />
|
/// <reference path="./beautylog.node.log.ts" />
|
||||||
/// <reference path="./beautylog.node.code.ts" />
|
/// <reference path="./beautylog.node.code.ts" />
|
||||||
/// <reference path="./beautylog.node.table.ts" />
|
/// <reference path="./beautylog.node.table.ts" />
|
||||||
|
/// <reference path="./beautylog.node.figlet.ts" />
|
||||||
/// <reference path="./beautylog.browser.ts" />
|
/// <reference path="./beautylog.browser.ts" />
|
||||||
|
/// <reference path="./beautylog.promisechain.ts" />
|
||||||
|
|
||||||
var plugins = BeautylogPlugins.init();
|
var plugins = BeautylogPlugins.init();
|
||||||
var beautylog = (function() {
|
var beautylog = (function() {
|
||||||
|
@ -23,7 +23,7 @@ describe("beautylog",function(){
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe(".error(message)",function(){
|
describe(".error(message)",function(){
|
||||||
it("sould print a red error message",function(){
|
it("should print a red error message",function(){
|
||||||
beautylog.error('beautylog.error(), with normal logText, without logType');
|
beautylog.error('beautylog.error(), with normal logText, without logType');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -62,6 +62,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});
|
||||||
|
})
|
||||||
|
});
|
||||||
describe(".code",function(){
|
describe(".code",function(){
|
||||||
it("should highlight code",function(){
|
it("should highlight code",function(){
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
|
Loading…
Reference in New Issue
Block a user