diff --git a/README.md b/README.md index 0b28de1..864dc55 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ beautiful logging [![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 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 ```javascript diff --git a/index.d.ts b/index.d.ts index dd7accc..1a00dbb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -26,8 +26,13 @@ declare module BeautylogNodeTable { var cliTable: any; function init(): any; } +declare module BeautylogNodeFiglet { + var init: () => (textArg: string, optionsArg?: any) => void; +} declare module BeautylogBrowser { function init(): any; } +declare module BeautylogPromiseChain { +} declare var plugins: any; declare var beautylog: any; diff --git a/index.js b/index.js index f3b78fe..9e67901 100644 --- a/index.js +++ b/index.js @@ -3,10 +3,20 @@ /// var BeautylogPlugins; (function (BeautylogPlugins) { + var plugins = {}; BeautylogPlugins.init = function () { - var plugins = { - smartenv: require("smartenv") + plugins = { + 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; }; })(BeautylogPlugins || (BeautylogPlugins = {})); @@ -63,12 +73,11 @@ var ConsoleTable = (function () { var BeautylogNode; (function (BeautylogNode) { function init() { - plugins.colors = require("colors"); - plugins.clc = require("cli-color"); var beautylogNode = { log: BeautylogNodeLog.init(), - code: BeautylogNodeCode.init() - }; //object to append to all public facing functions + code: BeautylogNodeCode.init(), + figlet: BeautylogNodeFiglet.init() + }; /** * logs an directory to console * @param logText @@ -221,6 +230,36 @@ var BeautylogNodeTable; BeautylogNodeTable.init = init; })(BeautylogNodeTable || (BeautylogNodeTable = {})); /// +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 = {})); +/// var BeautylogBrowser; (function (BeautylogBrowser) { function init() { @@ -244,6 +283,7 @@ var BeautylogBrowser; } BeautylogBrowser.init = init; })(BeautylogBrowser || (BeautylogBrowser = {})); +/// /// /// /// @@ -251,7 +291,9 @@ var BeautylogBrowser; /// /// /// +/// /// +/// var plugins = BeautylogPlugins.init(); var beautylog = (function () { switch (plugins.smartenv.getEnv().runtimeEnv) { diff --git a/package.json b/package.json index efa1410..6c8f91f 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,10 @@ "cli-color": "^1.1.0", "cli-table2": "^0.2.0", "colors": "1.1.2", + "figlet": "^1.1.1", "hlight": "0.0.7", + "lodash": "^4.3.0", + "q": "^1.4.1", "smartenv": "0.0.15" }, "devDependencies": { diff --git a/test/test.js b/test/test.js index 16cccca..92625e6 100644 --- a/test/test.js +++ b/test/test.js @@ -24,7 +24,7 @@ describe("beautylog", 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'); }); }); @@ -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 () { it("should highlight code", function () { this.timeout(10000); diff --git a/ts/beautylog.node.figlet.ts b/ts/beautylog.node.figlet.ts new file mode 100644 index 0000000..f54179a --- /dev/null +++ b/ts/beautylog.node.figlet.ts @@ -0,0 +1,29 @@ +/// +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; + }; +} diff --git a/ts/beautylog.node.ts b/ts/beautylog.node.ts index 147abde..975cf08 100644 --- a/ts/beautylog.node.ts +++ b/ts/beautylog.node.ts @@ -1,13 +1,12 @@ /// module BeautylogNode { export function init() { - plugins.colors = require("colors"); - plugins.clc = require("cli-color"); var beautylogNode:any = { log:BeautylogNodeLog.init(), - code:BeautylogNodeCode.init() - }; //object to append to all public facing functions + code:BeautylogNodeCode.init(), + figlet:BeautylogNodeFiglet.init() + }; /** * logs an directory to console diff --git a/ts/beautylog.plugins.ts b/ts/beautylog.plugins.ts index b631d36..81cf4f0 100644 --- a/ts/beautylog.plugins.ts +++ b/ts/beautylog.plugins.ts @@ -1,9 +1,19 @@ /// module BeautylogPlugins { + var plugins:any = {}; export var init = function(){ - var plugins:any = { - smartenv: require("smartenv") + plugins = { + 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; }; } \ No newline at end of file diff --git a/ts/beautylog.promisechain.ts b/ts/beautylog.promisechain.ts new file mode 100644 index 0000000..f0999a9 --- /dev/null +++ b/ts/beautylog.promisechain.ts @@ -0,0 +1,4 @@ +/// +module BeautylogPromiseChain { + +} \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index f82f335..62f9fbc 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -5,7 +5,9 @@ /// /// /// +/// /// +/// var plugins = BeautylogPlugins.init(); var beautylog = (function() { diff --git a/ts/test.ts b/ts/test.ts index 0c8d57d..6dc2983 100644 --- a/ts/test.ts +++ b/ts/test.ts @@ -23,7 +23,7 @@ describe("beautylog",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'); }); }); @@ -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(){ it("should highlight code",function(){ this.timeout(10000);