Comparing version 1.2.9 to 1.2.11
/** | ||
* logdown - Debug utility with markdown support that runs on browser and server | ||
* | ||
* @version v1.2.9 | ||
* @version v1.2.11 | ||
* @link https://github.com/caiogondim/logdown | ||
@@ -9,2 +9,2 @@ * @author Caio Gondim <me@caiogondim.com> (http://caiogondim.com) | ||
*/ | ||
!function(){"use strict";function e(r){if(!(this instanceof e))return new e(r);r=r||{};var o=void 0===r.prefix?"":r.prefix;return o=p(o),o&&c(o,x)?l(o,x):(this.markdown=void 0===r.markdown||r.markdown,this.prefix=o,x.push(this),f()?(this.prefixColor=m[g%m.length],g+=1):u()&&(this.prefixColor=v()),this)}function r(e){for(var r=[],n=o(e);n;)e=e.replace(n.rule.regexp,n.rule.replacer),f()&&(r.push(n.rule.style),r.push("color:inherit;")),n=o(e);return{text:e,styles:r}}function o(e){var r=[],o=[];return f()?o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-weight:bold;"},{regexp:/\_([^\_]+)\_/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-style:italic;"},{regexp:/\`([^\`]+)\`/,replacer:function(e,r){return"%c"+r+"%c"},style:"background:#FDF6E3; color:#586E75; padding:1px 5px; border-radius:4px;"}]:u()&&(o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"["+b.modifiers.bold[0]+"m"+r+"["+b.modifiers.bold[1]+"m"}},{regexp:/\_([^\_]+)\_/,replacer:function(e,r){return"["+b.modifiers.italic[0]+"m"+r+"["+b.modifiers.italic[1]+"m"}},{regexp:/\`([^\`]+)\`/,replacer:function(e,r){return"["+b.bgColors.bgYellow[0]+"m["+b.colors.black[0]+"m "+r+" ["+b.colors.black[1]+"m["+b.bgColors.bgYellow[1]+"m"}}]),o.forEach(function(o){var n=e.match(o.regexp);n&&r.push({rule:o,match:n})}),0===r.length?null:(r.sort(function(e,r){return e.match.index-r.match.index}),r[0])}function n(e,o){var n,t,i,s;return"string"==typeof e?o.markdown&&a()?(n=r(e),t=n.text,i=n.styles):(t=e,i=[]):(t=t||"",i=i||[],s=e),o.prefix&&(a()?(t="%c"+o.prefix+"%c "+t,i.unshift("color:"+o.prefixColor+"; font-weight:bold;","color:inherit;")):t="["+o.prefix+"] "+t),{parsedText:t,styles:i,notText:s}}function t(e,o){var n,t="";return o.prefix&&(t=a()?"["+o.prefixColor[0]+"m["+b.modifiers.bold[0]+"m"+o.prefix+"["+b.modifiers.bold[1]+"m["+o.prefixColor[1]+"m ":"["+o.prefix+"] "),"string"==typeof e?t+=o.markdown?r(e).text:e:n=e,{parsedText:t,styles:[],notText:n}}function i(r){var o=null;"undefined"!=typeof process&&void 0!==process.env&&0===h.length&&(void 0!==process.env.NODE_DEBUG&&""!==process.env.NODE_DEBUG?o="NODE_DEBUG":void 0!==process.env.DEBUG&&""!==process.env.DEBUG&&(o="DEBUG"),o&&(e.disable("*"),process.env[o].split(",").forEach(function(r){e.enable(r)})));var n=!1;return h.forEach(function(e){"enable"===e.type&&e.regExp.test(r.prefix)?n=!1:"disable"===e.type&&e.regExp.test(r.prefix)&&(n=!0)}),n}function s(e){return new RegExp("^"+e.replace(/\*/g,".*?")+"$")}function c(e,r){var o=!1;return r.forEach(function(r){if(r.prefix===e)return void(o=!0)}),o}function l(e,r){var o;return r.forEach(function(r){if(r.prefix===e)return void(o=r)}),o}function p(e){return"string"==typeof e?e.replace(/\%c/g,""):e}function a(){if(f()){var e="WebkitAppearance"in document.documentElement.style,r=window.console&&(console.firebug||console.exception&&console.table),o=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31;return e||r||o}if(u())return!(process.stdout&&!process.stdout.isTTY)&&("win32"===process.platform||("COLORTERM"in process.env||"dumb"!==process.env.TERM&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)))}function u(){return"undefined"!=typeof module&&"undefined"!=typeof module.exports}function f(){return"undefined"!=typeof window}function d(e){return e}var x=[],g=0,m=["#B58900","#CB4B16","#DC322F","#D33682","#6C71C4","#268BD2","#2AA198","#859900"],b={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}},h=[];e.enable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.disable(r.substr(1));var o=s(r);"*"===r?h=[]:h.push({type:"enable",regExp:o})})},e.disable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.enable(r.substr(1));var o=s(r);"*"===r?h=[{type:"disable",regExp:o}]:h.push({type:"disable",regExp:o})})};var y=["debug","log","info","warn","error"];y.forEach(function(r){e.prototype[r]=function(){var e,o=[];if(!i(this)){var s=Array.prototype.slice.call(arguments,0).join(" ");f()?(s=p(s),e=n(s,this),Function.prototype.apply.call(console[r]||console.log,console,[e.parsedText].concat(e.styles,"undefined"!=typeof e.notText?[e.notText]:""))):u()&&(s=d(s),e=t(s,this),"warn"===r?e.parsedText="["+b.colors.yellow[0]+"m⚠["+b.colors.yellow[1]+"m "+e.parsedText:"error"===r?e.parsedText="["+b.colors.red[0]+"m✖["+b.colors.red[1]+"m "+e.parsedText:"info"===r?e.parsedText="["+b.colors.blue[0]+"mℹ["+b.colors.blue[1]+"m "+e.parsedText:"debug"===r&&(e.parsedText="["+b.colors.gray[0]+"m🐛["+b.colors.gray[1]+"m "+e.parsedText),o.push(e.parsedText),e.notText&&o.push(e.notText),(console[r]||console.log).apply(console,o))}}});var v=function(){var e=0,r=[[31,39],[32,39],[33,39],[34,39],[35,39],[36,39]];return function(){return r[(e+=1)%r.length]}}();u()?module.exports=e:f()&&(window.Logdown=e)}(); | ||
!function(){"use strict";function e(r){if(!(this instanceof e))return new e(r);r=r||{};var o=void 0===r.prefix?"":r.prefix;return o=p(o),o&&c(o,x)?l(o,x):(this.markdown=void 0===r.markdown?!0:r.markdown,this.prefix=o,x.push(this),f()?(this.prefixColor=m[g%m.length],g+=1):u()&&(this.prefixColor=v()),this)}function r(e){for(var r=[],n=o(e);n;)e=e.replace(n.rule.regexp,n.rule.replacer),f()&&(r.push(n.rule.style),r.push("color:inherit;")),n=o(e);return{text:e,styles:r}}function o(e){var r=[],o=[];return f()?o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-weight:bold;"},{regexp:/_([^_]+)_/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-style:italic;"},{regexp:/`([^`]+)`/,replacer:function(e,r){return"%c"+r+"%c"},style:"background:#FDF6E3; color:#586E75; padding:1px 5px; border-radius:4px;"}]:u()&&(o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"["+b.modifiers.bold[0]+"m"+r+"["+b.modifiers.bold[1]+"m"}},{regexp:/_([^_]+)_/,replacer:function(e,r){return"["+b.modifiers.italic[0]+"m"+r+"["+b.modifiers.italic[1]+"m"}},{regexp:/`([^`]+)`/,replacer:function(e,r){return"["+b.bgColors.bgYellow[0]+"m["+b.colors.black[0]+"m "+r+" ["+b.colors.black[1]+"m["+b.bgColors.bgYellow[1]+"m"}}]),o.forEach(function(o){var n=e.match(o.regexp);n&&r.push({rule:o,match:n})}),0===r.length?null:(r.sort(function(e,r){return e.match.index-r.match.index}),r[0])}function n(e,o){var n,t,i,s;return"string"==typeof e?o.markdown&&a()?(n=r(e),t=n.text,i=n.styles):(t=e,i=[]):(t=t||"",i=i||[],s=e),o.prefix&&(a()?(t="%c"+o.prefix+"%c "+t,i.unshift("color:"+o.prefixColor+"; font-weight:bold;","color:inherit;")):t="["+o.prefix+"] "+t),{parsedText:t,styles:i,notText:s}}function t(e,o){var n,t="";return o.prefix&&(t=a()?"["+o.prefixColor[0]+"m["+b.modifiers.bold[0]+"m"+o.prefix+"["+b.modifiers.bold[1]+"m["+o.prefixColor[1]+"m ":"["+o.prefix+"] "),"string"==typeof e?t+=o.markdown?r(e).text:e:n=e,{parsedText:t,styles:[],notText:n}}function i(r){var o=null;"undefined"!=typeof process&&void 0!==process.env&&0===h.length&&(void 0!==process.env.NODE_DEBUG&&""!==process.env.NODE_DEBUG?o="NODE_DEBUG":void 0!==process.env.DEBUG&&""!==process.env.DEBUG&&(o="DEBUG"),o&&(e.disable("*"),process.env[o].split(",").forEach(function(r){e.enable(r)})));var n=!1;return h.forEach(function(e){"enable"===e.type&&e.regExp.test(r.prefix)?n=!1:"disable"===e.type&&e.regExp.test(r.prefix)&&(n=!0)}),n}function s(e){return new RegExp("^"+e.replace(/\*/g,".*?")+"$")}function c(e,r){var o=!1;return r.forEach(function(r){return r.prefix===e?void(o=!0):void 0}),o}function l(e,r){var o;return r.forEach(function(r){return r.prefix===e?void(o=r):void 0}),o}function p(e){return"string"==typeof e?e.replace(/%c/g,""):e}function a(){if(f()){var e="WebkitAppearance"in document.documentElement.style,r=window.console&&(console.firebug||console.exception&&console.table),o=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31;return e||r||o}return u()?process.stdout&&!process.stdout.isTTY?!1:"win32"===process.platform?!0:"COLORTERM"in process.env?!0:"dumb"===process.env.TERM?!1:!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM):void 0}function u(){return"undefined"!=typeof module&&"undefined"!=typeof module.exports}function f(){return"undefined"!=typeof window}function d(e){return e}var x=[],g=0,m=["#B58900","#CB4B16","#DC322F","#D33682","#6C71C4","#268BD2","#2AA198","#859900"],b={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}},h=[];e.enable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.disable(r.substr(1));var o=s(r);"*"===r?h=[]:h.push({type:"enable",regExp:o})})},e.disable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.enable(r.substr(1));var o=s(r);"*"===r?h=[{type:"disable",regExp:o}]:h.push({type:"disable",regExp:o})})};var y=["debug","log","info","warn","error"];y.forEach(function(r){e.prototype[r]=function(){var e,o=[];if(!i(this)){var s=Array.prototype.slice.call(arguments,0).join(" ");f()?(s=p(s),e=n(s,this),Function.prototype.apply.call(console[r]||console.log,console,[e.parsedText].concat(e.styles,"undefined"!=typeof e.notText?[e.notText]:""))):u()&&(s=d(s),e=t(s,this),"warn"===r?e.parsedText="["+b.colors.yellow[0]+"m⚠["+b.colors.yellow[1]+"m "+e.parsedText:"error"===r?e.parsedText="["+b.colors.red[0]+"m✖["+b.colors.red[1]+"m "+e.parsedText:"info"===r?e.parsedText="["+b.colors.blue[0]+"mℹ["+b.colors.blue[1]+"m "+e.parsedText:"debug"===r&&(e.parsedText="["+b.colors.gray[0]+"m🐛["+b.colors.gray[1]+"m "+e.parsedText),o.push(e.parsedText),e.notText&&o.push(e.notText),(console[r]||console.log).apply(console,o))}}});var v=function(){var e=0,r=[[31,39],[32,39],[33,39],[34,39],[35,39],[36,39]];return function(){return r[(e+=1)%r.length]}}();u()?module.exports=e:f()&&(window.Logdown=e)}(); |
/** | ||
* logdown - Debug utility with markdown support that runs on browser and server | ||
* | ||
* @version v1.2.9 | ||
* @version v1.2.11 | ||
* @link https://github.com/caiogondim/logdown | ||
@@ -9,2 +9,2 @@ * @author Caio Gondim <me@caiogondim.com> (http://caiogondim.com) | ||
*/ | ||
!function(){"use strict";function e(r){if(!(this instanceof e))return new e(r);r=r||{};var o=void 0===r.prefix?"":r.prefix;return o=p(o),o&&c(o,x)?l(o,x):(this.markdown=void 0===r.markdown||r.markdown,this.prefix=o,x.push(this),f()?(this.prefixColor=m[g%m.length],g+=1):u()&&(this.prefixColor=v()),this)}function r(e){for(var r=[],n=o(e);n;)e=e.replace(n.rule.regexp,n.rule.replacer),f()&&(r.push(n.rule.style),r.push("color:inherit;")),n=o(e);return{text:e,styles:r}}function o(e){var r=[],o=[];return f()?o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-weight:bold;"},{regexp:/\_([^\_]+)\_/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-style:italic;"},{regexp:/\`([^\`]+)\`/,replacer:function(e,r){return"%c"+r+"%c"},style:"background:#FDF6E3; color:#586E75; padding:1px 5px; border-radius:4px;"}]:u()&&(o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"["+b.modifiers.bold[0]+"m"+r+"["+b.modifiers.bold[1]+"m"}},{regexp:/\_([^\_]+)\_/,replacer:function(e,r){return"["+b.modifiers.italic[0]+"m"+r+"["+b.modifiers.italic[1]+"m"}},{regexp:/\`([^\`]+)\`/,replacer:function(e,r){return"["+b.bgColors.bgYellow[0]+"m["+b.colors.black[0]+"m "+r+" ["+b.colors.black[1]+"m["+b.bgColors.bgYellow[1]+"m"}}]),o.forEach(function(o){var n=e.match(o.regexp);n&&r.push({rule:o,match:n})}),0===r.length?null:(r.sort(function(e,r){return e.match.index-r.match.index}),r[0])}function n(e,o){var n,t,i,s;return"string"==typeof e?o.markdown&&a()?(n=r(e),t=n.text,i=n.styles):(t=e,i=[]):(t=t||"",i=i||[],s=e),o.prefix&&(a()?(t="%c"+o.prefix+"%c "+t,i.unshift("color:"+o.prefixColor+"; font-weight:bold;","color:inherit;")):t="["+o.prefix+"] "+t),{parsedText:t,styles:i,notText:s}}function t(e,o){var n,t="";return o.prefix&&(t=a()?"["+o.prefixColor[0]+"m["+b.modifiers.bold[0]+"m"+o.prefix+"["+b.modifiers.bold[1]+"m["+o.prefixColor[1]+"m ":"["+o.prefix+"] "),"string"==typeof e?t+=o.markdown?r(e).text:e:n=e,{parsedText:t,styles:[],notText:n}}function i(r){var o=null;"undefined"!=typeof process&&void 0!==process.env&&0===h.length&&(void 0!==process.env.NODE_DEBUG&&""!==process.env.NODE_DEBUG?o="NODE_DEBUG":void 0!==process.env.DEBUG&&""!==process.env.DEBUG&&(o="DEBUG"),o&&(e.disable("*"),process.env[o].split(",").forEach(function(r){e.enable(r)})));var n=!1;return h.forEach(function(e){"enable"===e.type&&e.regExp.test(r.prefix)?n=!1:"disable"===e.type&&e.regExp.test(r.prefix)&&(n=!0)}),n}function s(e){return new RegExp("^"+e.replace(/\*/g,".*?")+"$")}function c(e,r){var o=!1;return r.forEach(function(r){if(r.prefix===e)return void(o=!0)}),o}function l(e,r){var o;return r.forEach(function(r){if(r.prefix===e)return void(o=r)}),o}function p(e){return"string"==typeof e?e.replace(/\%c/g,""):e}function a(){if(f()){var e="WebkitAppearance"in document.documentElement.style,r=window.console&&(console.firebug||console.exception&&console.table),o=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31;return e||r||o}if(u())return!(process.stdout&&!process.stdout.isTTY)&&("win32"===process.platform||("COLORTERM"in process.env||"dumb"!==process.env.TERM&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)))}function u(){return"undefined"!=typeof module&&"undefined"!=typeof module.exports}function f(){return"undefined"!=typeof window}function d(e){return e}var x=[],g=0,m=["#B58900","#CB4B16","#DC322F","#D33682","#6C71C4","#268BD2","#2AA198","#859900"],b={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}},h=[];e.enable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.disable(r.substr(1));var o=s(r);"*"===r?h=[]:h.push({type:"enable",regExp:o})})},e.disable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.enable(r.substr(1));var o=s(r);"*"===r?h=[{type:"disable",regExp:o}]:h.push({type:"disable",regExp:o})})};var y=["debug","log","info","warn","error"];y.forEach(function(r){e.prototype[r]=function(){var e,o=[];if(!i(this)){var s=Array.prototype.slice.call(arguments,0).join(" ");f()?(s=p(s),e=n(s,this),Function.prototype.apply.call(console[r]||console.log,console,[e.parsedText].concat(e.styles,"undefined"!=typeof e.notText?[e.notText]:""))):u()&&(s=d(s),e=t(s,this),"warn"===r?e.parsedText="["+b.colors.yellow[0]+"m⚠["+b.colors.yellow[1]+"m "+e.parsedText:"error"===r?e.parsedText="["+b.colors.red[0]+"m✖["+b.colors.red[1]+"m "+e.parsedText:"info"===r?e.parsedText="["+b.colors.blue[0]+"mℹ["+b.colors.blue[1]+"m "+e.parsedText:"debug"===r&&(e.parsedText="["+b.colors.gray[0]+"m🐛["+b.colors.gray[1]+"m "+e.parsedText),o.push(e.parsedText),e.notText&&o.push(e.notText),(console[r]||console.log).apply(console,o))}}});var v=function(){var e=0,r=[[31,39],[32,39],[33,39],[34,39],[35,39],[36,39]];return function(){return r[(e+=1)%r.length]}}();u()?module.exports=e:f()&&(window.Logdown=e)}(); | ||
!function(){"use strict";function e(r){if(!(this instanceof e))return new e(r);r=r||{};var o=void 0===r.prefix?"":r.prefix;return o=p(o),o&&c(o,x)?l(o,x):(this.markdown=void 0===r.markdown?!0:r.markdown,this.prefix=o,x.push(this),f()?(this.prefixColor=m[g%m.length],g+=1):u()&&(this.prefixColor=v()),this)}function r(e){for(var r=[],n=o(e);n;)e=e.replace(n.rule.regexp,n.rule.replacer),f()&&(r.push(n.rule.style),r.push("color:inherit;")),n=o(e);return{text:e,styles:r}}function o(e){var r=[],o=[];return f()?o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-weight:bold;"},{regexp:/_([^_]+)_/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-style:italic;"},{regexp:/`([^`]+)`/,replacer:function(e,r){return"%c"+r+"%c"},style:"background:#FDF6E3; color:#586E75; padding:1px 5px; border-radius:4px;"}]:u()&&(o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"["+b.modifiers.bold[0]+"m"+r+"["+b.modifiers.bold[1]+"m"}},{regexp:/_([^_]+)_/,replacer:function(e,r){return"["+b.modifiers.italic[0]+"m"+r+"["+b.modifiers.italic[1]+"m"}},{regexp:/`([^`]+)`/,replacer:function(e,r){return"["+b.bgColors.bgYellow[0]+"m["+b.colors.black[0]+"m "+r+" ["+b.colors.black[1]+"m["+b.bgColors.bgYellow[1]+"m"}}]),o.forEach(function(o){var n=e.match(o.regexp);n&&r.push({rule:o,match:n})}),0===r.length?null:(r.sort(function(e,r){return e.match.index-r.match.index}),r[0])}function n(e,o){var n,t,i,s;return"string"==typeof e?o.markdown&&a()?(n=r(e),t=n.text,i=n.styles):(t=e,i=[]):(t=t||"",i=i||[],s=e),o.prefix&&(a()?(t="%c"+o.prefix+"%c "+t,i.unshift("color:"+o.prefixColor+"; font-weight:bold;","color:inherit;")):t="["+o.prefix+"] "+t),{parsedText:t,styles:i,notText:s}}function t(e,o){var n,t="";return o.prefix&&(t=a()?"["+o.prefixColor[0]+"m["+b.modifiers.bold[0]+"m"+o.prefix+"["+b.modifiers.bold[1]+"m["+o.prefixColor[1]+"m ":"["+o.prefix+"] "),"string"==typeof e?t+=o.markdown?r(e).text:e:n=e,{parsedText:t,styles:[],notText:n}}function i(r){var o=null;"undefined"!=typeof process&&void 0!==process.env&&0===h.length&&(void 0!==process.env.NODE_DEBUG&&""!==process.env.NODE_DEBUG?o="NODE_DEBUG":void 0!==process.env.DEBUG&&""!==process.env.DEBUG&&(o="DEBUG"),o&&(e.disable("*"),process.env[o].split(",").forEach(function(r){e.enable(r)})));var n=!1;return h.forEach(function(e){"enable"===e.type&&e.regExp.test(r.prefix)?n=!1:"disable"===e.type&&e.regExp.test(r.prefix)&&(n=!0)}),n}function s(e){return new RegExp("^"+e.replace(/\*/g,".*?")+"$")}function c(e,r){var o=!1;return r.forEach(function(r){return r.prefix===e?void(o=!0):void 0}),o}function l(e,r){var o;return r.forEach(function(r){return r.prefix===e?void(o=r):void 0}),o}function p(e){return"string"==typeof e?e.replace(/%c/g,""):e}function a(){if(f()){var e="WebkitAppearance"in document.documentElement.style,r=window.console&&(console.firebug||console.exception&&console.table),o=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31;return e||r||o}return u()?process.stdout&&!process.stdout.isTTY?!1:"win32"===process.platform?!0:"COLORTERM"in process.env?!0:"dumb"===process.env.TERM?!1:!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM):void 0}function u(){return"undefined"!=typeof module&&"undefined"!=typeof module.exports}function f(){return"undefined"!=typeof window}function d(e){return e}var x=[],g=0,m=["#B58900","#CB4B16","#DC322F","#D33682","#6C71C4","#268BD2","#2AA198","#859900"],b={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}},h=[];e.enable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.disable(r.substr(1));var o=s(r);"*"===r?h=[]:h.push({type:"enable",regExp:o})})},e.disable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.enable(r.substr(1));var o=s(r);"*"===r?h=[{type:"disable",regExp:o}]:h.push({type:"disable",regExp:o})})};var y=["debug","log","info","warn","error"];y.forEach(function(r){e.prototype[r]=function(){var e,o=[];if(!i(this)){var s=Array.prototype.slice.call(arguments,0).join(" ");f()?(s=p(s),e=n(s,this),Function.prototype.apply.call(console[r]||console.log,console,[e.parsedText].concat(e.styles,"undefined"!=typeof e.notText?[e.notText]:""))):u()&&(s=d(s),e=t(s,this),"warn"===r?e.parsedText="["+b.colors.yellow[0]+"m⚠["+b.colors.yellow[1]+"m "+e.parsedText:"error"===r?e.parsedText="["+b.colors.red[0]+"m✖["+b.colors.red[1]+"m "+e.parsedText:"info"===r?e.parsedText="["+b.colors.blue[0]+"mℹ["+b.colors.blue[1]+"m "+e.parsedText:"debug"===r&&(e.parsedText="["+b.colors.gray[0]+"m🐛["+b.colors.gray[1]+"m "+e.parsedText),o.push(e.parsedText),e.notText&&o.push(e.notText),(console[r]||console.log).apply(console,o))}}});var v=function(){var e=0,r=[[31,39],[32,39],[33,39],[34,39],[35,39],[36,39]];return function(){return r[(e+=1)%r.length]}}();u()?module.exports=e:f()&&(window.Logdown=e)}(); |
@@ -1,3 +0,1 @@ | ||
/* jshint node:true */ | ||
'use strict' | ||
@@ -7,4 +5,2 @@ | ||
var mocha = require('gulp-mocha') | ||
var jshint = require('gulp-jshint') | ||
var jscs = require('gulp-jscs') | ||
var uglify = require('gulp-uglify') | ||
@@ -25,15 +21,3 @@ var header = require('gulp-header') | ||
gulp.task('jscs', function() { | ||
return gulp.src(jsFilesToBeStyleChecked) | ||
.pipe(jscs()) | ||
}) | ||
gulp.task('jshint', ['jscs'], function() { | ||
return gulp.src(jsFilesToBeStyleChecked) | ||
.pipe(jshint('.jshintrc')) | ||
.pipe(jshint.reporter('jshint-stylish')) | ||
.pipe(jshint.reporter('fail')) | ||
}) | ||
gulp.task('mocha', ['jshint'], function() { | ||
gulp.task('mocha', function() { | ||
return gulp.src(['test/server/*.js', 'test/server.js']) | ||
@@ -40,0 +24,0 @@ .pipe(mocha()) |
{ | ||
"name": "logdown", | ||
"version": "1.2.9", | ||
"version": "1.2.11", | ||
"description": "Debug utility with markdown support that runs on browser and server", | ||
@@ -10,3 +10,5 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"test": "gulp test", | ||
"test": "npm run test:lint && gulp test", | ||
"test:lint": "standard './src/**/*.js' './test/**/*.js'", | ||
"test:lint:fix": "standard './src/**/*.js' './test/**/*.js' --fix", | ||
"build": "gulp build", | ||
@@ -42,9 +44,5 @@ "deploy:example": "gulp deploy:example", | ||
"gulp-header": "^1.8.2", | ||
"gulp-jscs": "^3.0.0", | ||
"gulp-jshint": "^2.0.0", | ||
"gulp-mocha": "^2.2.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-uglify": "^1.5.3", | ||
"jshint": "^2.9.1", | ||
"jshint-stylish": "^2.2.0", | ||
"karma": "^0.13.0", | ||
@@ -59,5 +57,6 @@ "karma-chai": "^0.1.0", | ||
"mocha": "^2.5.3", | ||
"sinon": "^1.17.4" | ||
"sinon": "^1.17.5", | ||
"standard": "^8.0.0" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -1,6 +0,6 @@ | ||
<img src="http://rawgit.com/caiogondim/logdown/master/img/icon.svg"> | ||
<img src="http://rawgit.com/caiogondim/logdown.js/master/img/icon.svg"> | ||
# Logdown | ||
<img src="http://travis-ci.org/caiogondim/logdown.js.svg?branch=master" alt="Travis CI"> <img src="http://david-dm.org/caiogondim/logdown/dev-status.svg" alt="David DM"> <img src="http://img.shields.io/npm/dm/logdown.svg" alt="Downloads per month"> [](https://logdown-slack.herokuapp.com/) | ||
<img src="http://travis-ci.org/caiogondim/logdown.js.svg?branch=master" alt="Travis CI"> <img src="http://david-dm.org/caiogondim/logdown.js/dev-status.svg" alt="David DM"> <img src="http://img.shields.io/npm/dm/logdown.svg" alt="Downloads per month"> [](https://logdown-slack.herokuapp.com/) | ||
@@ -17,6 +17,6 @@ Logdown is a debug utility for the browser and the server with Markdown support. | ||
### Browser | ||
<img src="http://rawgit.com/caiogondim/logdown/master/img/browser-preview.gif"> | ||
<img src="http://rawgit.com/caiogondim/logdown.js/master/img/browser-preview.gif"> | ||
### Server | ||
<img src="http://rawgit.com/caiogondim/logdown/master/img/node-preview.gif"> | ||
<img src="http://rawgit.com/caiogondim/logdown.js/master/img/node-preview.gif"> | ||
@@ -42,3 +42,3 @@ | ||
use [Browserify](http://browserify.org/). Or you can just download it | ||
[here](https://github.com/caiogondim/logdown/archive/master.zip) and put the | ||
[here](https://github.com/caiogondim/logdown.js/archive/master.zip) and put the | ||
`dist/index.js` file in your public folder. | ||
@@ -45,0 +45,0 @@ |
109
src/index.js
/* global console, module, window, document, navigator, process */ | ||
;(function() { | ||
;(function () { | ||
'use strict' | ||
@@ -53,6 +53,6 @@ | ||
} | ||
}; | ||
} | ||
var filterRegExps = [] | ||
function Logdown(opts) { | ||
function Logdown (opts) { | ||
// Enforces new. | ||
@@ -91,4 +91,4 @@ if (!(this instanceof Logdown)) { | ||
Logdown.enable = function() { | ||
Array.prototype.forEach.call(arguments, function(str) { | ||
Logdown.enable = function () { | ||
Array.prototype.forEach.call(arguments, function (str) { | ||
if (str[0] === '-') { | ||
@@ -111,4 +111,4 @@ Logdown.disable(str.substr(1)) | ||
Logdown.disable = function() { | ||
Array.prototype.forEach.call(arguments, function(str) { | ||
Logdown.disable = function () { | ||
Array.prototype.forEach.call(arguments, function (str) { | ||
if (str[0] === '-') { | ||
@@ -138,4 +138,4 @@ Logdown.enable(str.substr(1)) | ||
var methods = ['debug', 'log', 'info', 'warn', 'error'] | ||
methods.forEach(function(method) { | ||
Logdown.prototype[method] = function() { | ||
methods.forEach(function (method) { | ||
Logdown.prototype[method] = function () { | ||
var preparedOutput | ||
@@ -148,3 +148,3 @@ var args = [] | ||
var text = Array.prototype.slice.call(arguments, 0).join(' '); | ||
var text = Array.prototype.slice.call(arguments, 0).join(' ') | ||
// var text = arguments[0]; | ||
@@ -163,5 +163,8 @@ | ||
[preparedOutput.parsedText] | ||
.concat(preparedOutput.styles, | ||
typeof preparedOutput.notText !== 'undefined' ? | ||
[preparedOutput.notText] : '') | ||
.concat( | ||
preparedOutput.styles, | ||
typeof preparedOutput.notText !== 'undefined' | ||
? [preparedOutput.notText] | ||
: '' | ||
) | ||
) | ||
@@ -215,3 +218,3 @@ } else if (isNode()) { | ||
function parseMarkdown(text) { | ||
function parseMarkdown (text) { | ||
var styles = [] | ||
@@ -234,3 +237,3 @@ var match = getNextMatch(text) | ||
function getNextMatch(text) { | ||
function getNextMatch (text) { | ||
var matches = [] | ||
@@ -242,3 +245,3 @@ var rules = [] | ||
regexp: /\*([^\*]+)\*/, | ||
replacer: function(match, submatch1) { | ||
replacer: function (match, submatch1) { | ||
return '%c' + submatch1 + '%c' | ||
@@ -249,4 +252,4 @@ }, | ||
{ | ||
regexp: /\_([^\_]+)\_/, | ||
replacer: function(match, submatch1) { | ||
regexp: /_([^_]+)_/, | ||
replacer: function (match, submatch1) { | ||
return '%c' + submatch1 + '%c' | ||
@@ -257,5 +260,5 @@ }, | ||
{ | ||
regexp: /\`([^\`]+)\`/, | ||
replacer: function(match, submatch1) { | ||
return '%c' + submatch1 + '%c'; | ||
regexp: /`([^`]+)`/, | ||
replacer: function (match, submatch1) { | ||
return '%c' + submatch1 + '%c' | ||
}, | ||
@@ -273,3 +276,3 @@ style: | ||
regexp: /\*([^\*]+)\*/, | ||
replacer: function(match, submatch1) { | ||
replacer: function (match, submatch1) { | ||
return '\u001b[' + ansiColors.modifiers.bold[0] + 'm' + | ||
@@ -281,4 +284,4 @@ submatch1 + | ||
{ | ||
regexp: /\_([^\_]+)\_/, | ||
replacer: function(match, submatch1) { | ||
regexp: /_([^_]+)_/, | ||
replacer: function (match, submatch1) { | ||
return '\u001b[' + ansiColors.modifiers.italic[0] + 'm' + | ||
@@ -290,4 +293,4 @@ submatch1 + | ||
{ | ||
regexp: /\`([^\`]+)\`/, | ||
replacer: function(match, submatch1) { | ||
regexp: /`([^`]+)`/, | ||
replacer: function (match, submatch1) { | ||
return '\u001b[' + ansiColors.bgColors.bgYellow[0] + 'm' + | ||
@@ -304,3 +307,3 @@ '\u001b[' + ansiColors.colors.black[0] + 'm' + | ||
// | ||
rules.forEach(function(rule) { | ||
rules.forEach(function (rule) { | ||
var match = text.match(rule.regexp) | ||
@@ -315,7 +318,7 @@ if (match) { | ||
if (matches.length === 0) { | ||
return null; | ||
return null | ||
} | ||
// | ||
matches.sort(function(a, b) { | ||
matches.sort(function (a, b) { | ||
return a.match.index - b.match.index | ||
@@ -327,3 +330,3 @@ }) | ||
function prepareOutputToBrowser(data, instance) { | ||
function prepareOutputToBrowser (data, instance) { | ||
var parsedMarkdown | ||
@@ -370,3 +373,3 @@ var parsedText | ||
function prepareOutputToNode(data, instance) { | ||
function prepareOutputToNode (data, instance) { | ||
var parsedText = '' | ||
@@ -405,3 +408,3 @@ var notText | ||
function isDisabled(instance) { | ||
function isDisabled (instance) { | ||
// Parsing `NODE_DEBUG` and `DEBUG` env var. | ||
@@ -427,3 +430,3 @@ // We verify `NODE_DEBUG` and `DEBUG` env vars on runtime so it is | ||
.split(',') | ||
.forEach(function(regExp) { | ||
.forEach(function (regExp) { | ||
Logdown.enable(regExp) | ||
@@ -436,3 +439,3 @@ }) | ||
var isDisabled_ = false | ||
filterRegExps.forEach(function(filter) { | ||
filterRegExps.forEach(function (filter) { | ||
if (filter.type === 'enable' && filter.regExp.test(instance.prefix)) { | ||
@@ -449,10 +452,10 @@ isDisabled_ = false | ||
function prepareRegExpForPrefixSearch(str) { | ||
function prepareRegExpForPrefixSearch (str) { | ||
return new RegExp('^' + str.replace(/\*/g, '.*?') + '$') | ||
} | ||
function isPrefixAlreadyInUse(prefix, instances) { | ||
function isPrefixAlreadyInUse (prefix, instances) { | ||
var isPrefixAlreadyInUse_ = false | ||
instances.forEach(function(instance) { | ||
instances.forEach(function (instance) { | ||
if (instance.prefix === prefix) { | ||
@@ -467,6 +470,6 @@ isPrefixAlreadyInUse_ = true | ||
function getInstanceByPrefix(prefix, instances) { | ||
function getInstanceByPrefix (prefix, instances) { | ||
var instance | ||
instances.forEach(function(instanceCur) { | ||
instances.forEach(function (instanceCur) { | ||
if (instanceCur.prefix === prefix) { | ||
@@ -481,5 +484,5 @@ instance = instanceCur | ||
function sanitizeStringToBrowser(str) { | ||
function sanitizeStringToBrowser (str) { | ||
if (typeof str === 'string') { | ||
return str.replace(/\%c/g, '') | ||
return str.replace(/%c/g, '') | ||
} else { | ||
@@ -497,3 +500,3 @@ return str | ||
*/ | ||
function isColorSupported() { | ||
function isColorSupported () { | ||
if (isBrowser()) { | ||
@@ -518,15 +521,15 @@ // Is webkit? http://stackoverflow.com/a/16459606/376773 | ||
if (process.stdout && !process.stdout.isTTY) { | ||
return false; | ||
return false | ||
} | ||
if (process.platform === 'win32') { | ||
return true; | ||
return true | ||
} | ||
if ('COLORTERM' in process.env) { | ||
return true; | ||
return true | ||
} | ||
if (process.env.TERM === 'dumb') { | ||
return false; | ||
return false | ||
} | ||
@@ -537,3 +540,3 @@ | ||
) { | ||
return true; | ||
return true | ||
} | ||
@@ -545,3 +548,3 @@ | ||
function isNode() { | ||
function isNode () { | ||
return ( | ||
@@ -553,11 +556,11 @@ typeof module !== 'undefined' && | ||
function isBrowser() { | ||
function isBrowser () { | ||
return (typeof window !== 'undefined') | ||
} | ||
function sanitizeStringToNode(str) { | ||
return str; | ||
function sanitizeStringToNode (str) { | ||
return str | ||
} | ||
var getNextPrefixColor = (function() { | ||
var getNextPrefixColor = (function () { | ||
var lastUsed = 0 | ||
@@ -573,3 +576,3 @@ var nodePrefixColors = [ | ||
return function() { | ||
return function () { | ||
return nodePrefixColors[(lastUsed += 1) % nodePrefixColors.length] | ||
@@ -576,0 +579,0 @@ } |
@@ -1,7 +0,4 @@ | ||
/* global describe, afterEach, beforeEach, console, it, require, window, | ||
global, Logdown, chai, sinon, xit */ | ||
/* jshint -W038 */ | ||
/* jshint unused:false */ | ||
/* global describe, console, it, require, window, Logdown, chai, sinon */ | ||
;(function() { | ||
;(function () { | ||
'use strict' | ||
@@ -12,11 +9,11 @@ | ||
describe('new Logdown()', function() { | ||
describe('new Logdown()', function () { | ||
it('should return an existing instance if the prefix is already in use', | ||
function() { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var foo2 = new Logdown({prefix: 'foo'}) | ||
assert.equal(foo, foo2) | ||
}) | ||
function () { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var foo2 = new Logdown({prefix: 'foo'}) | ||
assert.equal(foo, foo2) | ||
}) | ||
it('should give a new prefix color for each instance', function() { | ||
it('should give a new prefix color for each instance', function () { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
@@ -31,3 +28,3 @@ var bar = new Logdown({prefix: 'bar'}) | ||
it('should sanitize prefixes name', function() { | ||
it('should sanitize prefixes name', function () { | ||
var log1 = new Logdown({prefix: '%cfoo%c'}) | ||
@@ -34,0 +31,0 @@ assert.equal(log1.prefix, 'foo') |
@@ -1,8 +0,5 @@ | ||
/* global describe, afterEach, beforeEach, console, it, require, window, | ||
Logdown, chai, sinon, xit */ | ||
/* jshint -W038 */ | ||
/* jshint unused:false */ | ||
/* global describe, beforeEach, console, it, require, window, Logdown, chai, sinon */ | ||
;(function() { | ||
'use strict'; | ||
;(function () { | ||
'use strict' | ||
@@ -12,3 +9,3 @@ sinon.assert.expose(chai.assert, {prefix: ''}) | ||
function createInstances() { | ||
function createInstances () { | ||
return [ | ||
@@ -22,6 +19,6 @@ new Logdown({prefix: 'foo'}), | ||
describe('Logdown.disable', function() { | ||
describe('Logdown.disable', function () { | ||
var sandbox | ||
beforeEach(function() { | ||
beforeEach(function () { | ||
sandbox = sinon.sandbox.create() | ||
@@ -32,7 +29,7 @@ | ||
it('`(\'*\')` should disable all instances', function() { | ||
it('`(\'*\')` should disable all instances', function () { | ||
Logdown.enable('*') | ||
Logdown.disable('*') | ||
var instances = createInstances() | ||
instances.forEach(function(instance) { | ||
instances.forEach(function (instance) { | ||
instance.log('Lorem') | ||
@@ -47,28 +44,28 @@ }) | ||
it('`(\'foo\')` should disable only instances with “foo” prefix', | ||
function() { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
function () { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
Logdown.enable('*') | ||
Logdown.disable('foo') | ||
Logdown.enable('*') | ||
Logdown.disable('foo') | ||
foo.log('lorem') | ||
assert.notCalled(console.log) | ||
bar.log('lorem') | ||
quz.log('lorem') | ||
baz.log('lorem') | ||
assert.calledThrice(console.log) | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
foo.log('lorem') | ||
assert.notCalled(console.log) | ||
bar.log('lorem') | ||
quz.log('lorem') | ||
baz.log('lorem') | ||
assert.calledThrice(console.log) | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
sandbox.restore() | ||
}) | ||
it('`(\'*foo\')` should disable only instances with names ending' + | ||
'with “foo”', function() { | ||
'with “foo”', function () { | ||
try { | ||
@@ -98,3 +95,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'foo*\')` should disable only instances with names beginning ' + | ||
'with “foo”', function() { | ||
'with “foo”', function () { | ||
try { | ||
@@ -123,3 +120,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\')` should disable all instances', function() { | ||
it('`(\'*\')` should disable all instances', function () { | ||
try { | ||
@@ -129,3 +126,3 @@ Logdown.enable('*') | ||
var instances = createInstances() | ||
instances.forEach(function(instance) { | ||
instances.forEach(function (instance) { | ||
instance.log('Lorem') | ||
@@ -144,3 +141,3 @@ }) | ||
it('`(\'foo\')` should disable only instances with ' + | ||
'“foo” prefix', function() { | ||
'“foo” prefix', function () { | ||
try { | ||
@@ -170,3 +167,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-*foo\')` should disable all but instances with names ' + | ||
'ending with “foo”', function() { | ||
'ending with “foo”', function () { | ||
try { | ||
@@ -195,3 +192,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-foo*\')` should disable all but instances with names ' + | ||
'beginning with “foo”', function() { | ||
'beginning with “foo”', function () { | ||
try { | ||
@@ -219,7 +216,7 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'-*\')` should not disable any instances', function() { | ||
it('`(\'-*\')` should not disable any instances', function () { | ||
try { | ||
Logdown.disable('-*') | ||
var instances = createInstances() | ||
instances.forEach(function(instance) { | ||
instances.forEach(function (instance) { | ||
instance.log('Lorem') | ||
@@ -237,26 +234,26 @@ }) | ||
it('`(\'*\', \'-foo\')` should disable all but instances with “foo” prefix', | ||
function() { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
function () { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
Logdown.disable('*', '-foo') | ||
Logdown.disable('*', '-foo') | ||
bar.log('lorem') | ||
quz.log('lorem') | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.calledOnce(console.log) | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
bar.log('lorem') | ||
quz.log('lorem') | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.calledOnce(console.log) | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
sandbox.restore() | ||
}) | ||
it('should accept N arguments', function() { | ||
it('should accept N arguments', function () { | ||
try { | ||
@@ -263,0 +260,0 @@ var foo = new Logdown({prefix: 'foo'}) |
@@ -1,7 +0,4 @@ | ||
/* global describe, afterEach, beforeEach, console, it, require, window, | ||
Logdown, chai, sinon, xit */ | ||
/* jshint -W038 */ | ||
/* jshint unused:false */ | ||
/* global describe, afterEach, beforeEach, console, it, require, window, Logdown, chai, sinon */ | ||
;(function() { | ||
;(function () { | ||
'use strict' | ||
@@ -12,3 +9,3 @@ | ||
function createInstances() { | ||
function createInstances () { | ||
return [ | ||
@@ -22,6 +19,6 @@ new Logdown({prefix: 'foo'}), | ||
describe('Logdown.enable', function() { | ||
describe('Logdown.enable', function () { | ||
var sandbox | ||
beforeEach(function() { | ||
beforeEach(function () { | ||
sandbox = sinon.sandbox.create() | ||
@@ -32,7 +29,7 @@ | ||
afterEach(function() { | ||
afterEach(function () { | ||
sandbox.restore() | ||
}) | ||
it('`(\'*\')` should enable all instances', function() { | ||
it('`(\'*\')` should enable all instances', function () { | ||
try { | ||
@@ -42,3 +39,3 @@ Logdown.disable('*') | ||
var instances = createInstances() | ||
instances.forEach(function(instance) { | ||
instances.forEach(function (instance) { | ||
instance.log('Lorem') | ||
@@ -59,59 +56,59 @@ }) | ||
'`(\'foo\')` should enable only instances with “foo” prefix', | ||
function() { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
function () { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
Logdown.disable('*') | ||
Logdown.enable('foo') | ||
Logdown.disable('*') | ||
Logdown.enable('foo') | ||
bar.log('lorem') | ||
assert.notCalled(console.log) | ||
quz.log('lorem') | ||
assert.notCalled(console.log) | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.called(console.log) | ||
bar.log('lorem') | ||
assert.notCalled(console.log) | ||
quz.log('lorem') | ||
assert.notCalled(console.log) | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.called(console.log) | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
}) | ||
sandbox.restore() | ||
}) | ||
it('`(\'*foo\')` should enable only instances with names ending with “foo”', | ||
function() { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var foobar = new Logdown({prefix: 'foobar'}) | ||
var barfoo = new Logdown({prefix: 'barfoo'}) | ||
function () { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var foobar = new Logdown({prefix: 'foobar'}) | ||
var barfoo = new Logdown({prefix: 'barfoo'}) | ||
Logdown.disable('*') | ||
Logdown.enable('*foo') | ||
Logdown.disable('*') | ||
Logdown.enable('*foo') | ||
bar.log('lorem') | ||
foobar.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
barfoo.log('lorem') | ||
assert.calledTwice(console.log) | ||
bar.log('lorem') | ||
foobar.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
barfoo.log('lorem') | ||
assert.calledTwice(console.log) | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
sandbox.restore() | ||
}) | ||
it('`(\'foo*\')` should enable only instances with names ' + | ||
'beginning with “foo”', function() { | ||
'beginning with “foo”', function () { | ||
try { | ||
@@ -142,3 +139,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'-*\')` should disable all instances', function() { | ||
it('`(\'-*\')` should disable all instances', function () { | ||
try { | ||
@@ -166,3 +163,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-foo\')` should enable all but only instances ' + | ||
'with “foo” prefix', function() { | ||
'with “foo” prefix', function () { | ||
try { | ||
@@ -191,3 +188,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-*foo\')` should enable all but instances with names ' + | ||
'ending with “foo”', function() { | ||
'ending with “foo”', function () { | ||
try { | ||
@@ -216,3 +213,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-foo*\')` should enable all but instances with names ' + | ||
'beginning with “foo”', function() { | ||
'beginning with “foo”', function () { | ||
try { | ||
@@ -240,3 +237,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('should accept N arguments', function() { | ||
it('should accept N arguments', function () { | ||
try { | ||
@@ -243,0 +240,0 @@ var foo = new Logdown({prefix: 'foo'}) |
/* global describe, afterEach, beforeEach, console, it, require, window, | ||
Logdown, chai, sinon, xit */ | ||
/* jshint -W038 */ | ||
/* jshint unused:false */ | ||
;(function() { | ||
;(function () { | ||
'use strict' | ||
@@ -13,7 +11,7 @@ | ||
var methods = ['debug', 'log', 'info', 'warn', 'error'] | ||
methods.forEach(function(method) { | ||
describe('Logdown::' + method, function() { | ||
methods.forEach(function (method) { | ||
describe('Logdown::' + method, function () { | ||
var sandbox | ||
beforeEach(function() { | ||
beforeEach(function () { | ||
sandbox = sinon.sandbox.create() | ||
@@ -25,7 +23,7 @@ sandbox.stub(window.console, method) | ||
afterEach(function() { | ||
afterEach(function () { | ||
sandbox.restore() | ||
}) | ||
it('should parse markdown if enabled', function() { | ||
it('should parse markdown if enabled', function () { | ||
try { | ||
@@ -79,3 +77,3 @@ var foo = new Logdown({markdown: true}) | ||
it('should not parse markdown if disabled', function() { | ||
it('should not parse markdown if disabled', function () { | ||
try { | ||
@@ -109,7 +107,7 @@ var foo = new Logdown({markdown: false}) | ||
it('should sanitize forbidden characters', function() { | ||
it('should sanitize forbidden characters', function () { | ||
sandbox.restore() | ||
}) | ||
it('should print prefix if present', function() { | ||
it('should print prefix if present', function () { | ||
// var foo = new Logdown({prefix: 'foo'}) | ||
@@ -133,3 +131,3 @@ | ||
it('should sanitize strings', function() { | ||
it('should sanitize strings', function () { | ||
try { | ||
@@ -157,3 +155,3 @@ var foo = new Logdown() | ||
// https://github.com/caiogondim/logdown/issues/14 | ||
xit('should print not-string arguments as is', function() { | ||
xit('should print not-string arguments as is', function () { | ||
try { | ||
@@ -160,0 +158,0 @@ var foo = new Logdown() |
/* global module */ | ||
module.exports = function(config) { | ||
module.exports = function (config) { | ||
'use strict' | ||
@@ -59,3 +59,3 @@ | ||
singleRun: false | ||
}); | ||
}; | ||
}) | ||
} |
/* global module */ | ||
module.exports = function(config) { | ||
module.exports = function (config) { | ||
'use strict' | ||
@@ -58,3 +58,3 @@ | ||
singleRun: false | ||
}); | ||
}; | ||
}) | ||
} |
/* global describe, it */ | ||
/* jshint node:true */ | ||
@@ -13,11 +12,11 @@ 'use strict' | ||
describe('new Logdown()', function() { | ||
describe('new Logdown()', function () { | ||
it('should return an existing instance if the prefix is already in use', | ||
function() { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var foo2 = new Logdown({prefix: 'foo'}) | ||
assert.equal(foo, foo2) | ||
}) | ||
function () { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var foo2 = new Logdown({prefix: 'foo'}) | ||
assert.equal(foo, foo2) | ||
}) | ||
it('should give a new prefix color for each instance', function() { | ||
it('should give a new prefix color for each instance', function () { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
@@ -32,3 +31,3 @@ var bar = new Logdown({prefix: 'bar'}) | ||
it('should sanitize prefixes name', function() { | ||
it('should sanitize prefixes name', function () { | ||
var log1 = new Logdown({prefix: '%cfoo%c'}) | ||
@@ -35,0 +34,0 @@ assert.equal(log1.prefix, 'foo') |
/* global describe, it, beforeEach */ | ||
/* jshint node:true */ | ||
@@ -13,3 +12,3 @@ 'use strict' | ||
function createInstances() { | ||
function createInstances () { | ||
return [ | ||
@@ -23,6 +22,6 @@ new Logdown({prefix: 'foo'}), | ||
describe('Logdown.disable', function() { | ||
describe('Logdown.disable', function () { | ||
var sandbox | ||
beforeEach(function() { | ||
beforeEach(function () { | ||
sandbox = sinon.sandbox.create() | ||
@@ -34,7 +33,7 @@ sandbox.stub(global.console, 'log') | ||
it('`(\'*\')` should disable all instances', function() { | ||
it('`(\'*\')` should disable all instances', function () { | ||
Logdown.enable('*') | ||
Logdown.disable('*') | ||
var instances = createInstances() | ||
instances.forEach(function(instance) { | ||
instances.forEach(function (instance) { | ||
instance.log('Lorem') | ||
@@ -49,28 +48,28 @@ }) | ||
it('`(\'foo\')` should disable only instances with “foo” prefix', | ||
function() { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
function () { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
Logdown.enable('*') | ||
Logdown.disable('foo') | ||
Logdown.enable('*') | ||
Logdown.disable('foo') | ||
foo.log('lorem') | ||
assert.notCalled(console.log) | ||
bar.log('lorem') | ||
quz.log('lorem') | ||
baz.log('lorem') | ||
assert.calledThrice(console.log) | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
foo.log('lorem') | ||
assert.notCalled(console.log) | ||
bar.log('lorem') | ||
quz.log('lorem') | ||
baz.log('lorem') | ||
assert.calledThrice(console.log) | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
sandbox.restore() | ||
}) | ||
it('`(\'*foo\')` should disable only instances with names ending' + | ||
'with “foo”', function() { | ||
'with “foo”', function () { | ||
try { | ||
@@ -100,3 +99,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'foo*\')` should disable only instances with names beginning ' + | ||
'with “foo”', function() { | ||
'with “foo”', function () { | ||
try { | ||
@@ -125,3 +124,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\')` should disable all instances', function() { | ||
it('`(\'*\')` should disable all instances', function () { | ||
try { | ||
@@ -131,3 +130,3 @@ Logdown.enable('*') | ||
var instances = createInstances() | ||
instances.forEach(function(instance) { | ||
instances.forEach(function (instance) { | ||
instance.log('Lorem') | ||
@@ -146,3 +145,3 @@ }) | ||
it('`(\'foo\')` should disable only instances with ' + | ||
'“foo” prefix', function() { | ||
'“foo” prefix', function () { | ||
try { | ||
@@ -172,3 +171,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-*foo\')` should disable all but instances with names ' + | ||
'ending with “foo”', function() { | ||
'ending with “foo”', function () { | ||
try { | ||
@@ -197,3 +196,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-foo*\')` should disable all but instances with names ' + | ||
'beginning with “foo”', function() { | ||
'beginning with “foo”', function () { | ||
try { | ||
@@ -221,7 +220,7 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'-*\')` should not disable any instances', function() { | ||
it('`(\'-*\')` should not disable any instances', function () { | ||
try { | ||
Logdown.disable('-*') | ||
var instances = createInstances() | ||
instances.forEach(function(instance) { | ||
instances.forEach(function (instance) { | ||
instance.log('Lorem') | ||
@@ -239,26 +238,26 @@ }) | ||
it('`(\'*\', \'-foo\')` should disable all but instances with “foo” prefix', | ||
function() { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
function () { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
Logdown.disable('*', '-foo') | ||
Logdown.disable('*', '-foo') | ||
bar.log('lorem') | ||
quz.log('lorem') | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.calledOnce(console.log) | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
bar.log('lorem') | ||
quz.log('lorem') | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.calledOnce(console.log) | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
sandbox.restore() | ||
}) | ||
it('should accept N arguments', function() { | ||
it('should accept N arguments', function () { | ||
try { | ||
@@ -265,0 +264,0 @@ var foo = new Logdown({prefix: 'foo'}) |
/* global describe, it, beforeEach, afterEach */ | ||
/* jshint node:true */ | ||
@@ -13,3 +12,3 @@ 'use strict' | ||
function createInstances() { | ||
function createInstances () { | ||
return [ | ||
@@ -23,6 +22,6 @@ new Logdown({prefix: 'foo'}), | ||
describe('Logdown.enable', function() { | ||
describe('Logdown.enable', function () { | ||
var sandbox | ||
beforeEach(function() { | ||
beforeEach(function () { | ||
sandbox = sinon.sandbox.create() | ||
@@ -34,7 +33,7 @@ sandbox.stub(global.console, 'log') | ||
afterEach(function() { | ||
afterEach(function () { | ||
sandbox.restore() | ||
}) | ||
it('`(\'*\')` should enable all instances', function() { | ||
it('`(\'*\')` should enable all instances', function () { | ||
try { | ||
@@ -44,3 +43,3 @@ Logdown.disable('*') | ||
var instances = createInstances() | ||
instances.forEach(function(instance) { | ||
instances.forEach(function (instance) { | ||
instance.log('Lorem') | ||
@@ -60,59 +59,59 @@ }) | ||
it('`(\'foo\')` should enable only instances with “foo” prefix', | ||
function() { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
function () { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
Logdown.disable('*') | ||
Logdown.enable('foo') | ||
Logdown.disable('*') | ||
Logdown.enable('foo') | ||
bar.log('lorem') | ||
assert.notCalled(console.log) | ||
quz.log('lorem') | ||
assert.notCalled(console.log) | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.called(console.log) | ||
bar.log('lorem') | ||
assert.notCalled(console.log) | ||
quz.log('lorem') | ||
assert.notCalled(console.log) | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.called(console.log) | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
sandbox.restore() | ||
}) | ||
it('`(\'*foo\')` should enable only instances with names ending with “foo”', | ||
function() { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var foobar = new Logdown({prefix: 'foobar'}) | ||
var barfoo = new Logdown({prefix: 'barfoo'}) | ||
function () { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var foobar = new Logdown({prefix: 'foobar'}) | ||
var barfoo = new Logdown({prefix: 'barfoo'}) | ||
Logdown.disable('*') | ||
Logdown.enable('*foo') | ||
Logdown.disable('*') | ||
Logdown.enable('*foo') | ||
bar.log('lorem') | ||
foobar.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
barfoo.log('lorem') | ||
assert.calledTwice(console.log) | ||
bar.log('lorem') | ||
foobar.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
barfoo.log('lorem') | ||
assert.calledTwice(console.log) | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
sandbox.restore() | ||
}) | ||
it('`(\'foo*\')` should enable only instances with names ' + | ||
'beginning with “foo”', function() { | ||
'beginning with “foo”', function () { | ||
try { | ||
@@ -143,3 +142,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'-*\')` should disable all instances', function() { | ||
it('`(\'-*\')` should disable all instances', function () { | ||
try { | ||
@@ -167,3 +166,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-foo\')` should enable all but only instances ' + | ||
'with “foo” prefix', function() { | ||
'with “foo” prefix', function () { | ||
try { | ||
@@ -192,3 +191,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-*foo\')` should enable all but instances with names ' + | ||
'ending with “foo”', function() { | ||
'ending with “foo”', function () { | ||
try { | ||
@@ -217,3 +216,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`(\'*\', \'-foo*\')` should enable all but instances with names ' + | ||
'beginning with “foo”', function() { | ||
'beginning with “foo”', function () { | ||
try { | ||
@@ -241,3 +240,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('should accept N arguments', function() { | ||
it('should accept N arguments', function () { | ||
try { | ||
@@ -244,0 +243,0 @@ var foo = new Logdown({prefix: 'foo'}) |
/* global describe, it, beforeEach, afterEach, xit */ | ||
/* jshint node:true */ | ||
@@ -45,7 +44,7 @@ 'use strict' | ||
} | ||
}; | ||
} | ||
var methods = ['debug', 'log', 'info', 'warn', 'error'] | ||
methods.forEach(function(method) { | ||
describe('Logdown::' + method, function() { | ||
methods.forEach(function (method) { | ||
describe('Logdown::' + method, function () { | ||
var sandbox | ||
@@ -76,4 +75,4 @@ var symbol = '' | ||
beforeEach(function() { | ||
global.console[method] = global.console[method] || global.console.log; | ||
beforeEach(function () { | ||
global.console[method] = global.console[method] || global.console.log | ||
sandbox = sinon.sandbox.create() | ||
@@ -86,7 +85,7 @@ sandbox.stub(global.console, method) | ||
afterEach(function() { | ||
afterEach(function () { | ||
sandbox.restore() | ||
}) | ||
it('should output multiple arguments', function() { | ||
it('should output multiple arguments', function () { | ||
try { | ||
@@ -109,3 +108,3 @@ var foo = new Logdown({markdown: true}) | ||
it('should parse markdown in multiple arguments', function() { | ||
it('should parse markdown in multiple arguments', function () { | ||
try { | ||
@@ -132,3 +131,3 @@ var foo = new Logdown({markdown: true}) | ||
it('should parse markdown if enabled', function() { | ||
it('should parse markdown if enabled', function () { | ||
try { | ||
@@ -183,3 +182,3 @@ var foo = new Logdown({markdown: true}) | ||
it('should not parse markdown if disabled', function() { | ||
it('should not parse markdown if disabled', function () { | ||
try { | ||
@@ -213,7 +212,7 @@ var foo = new Logdown({markdown: false}) | ||
xit('should sanitize forbidden characters', function() { | ||
xit('should sanitize forbidden characters', function () { | ||
sandbox.restore() | ||
}) | ||
xit('should print prefix if present', function() { | ||
xit('should print prefix if present', function () { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
@@ -241,3 +240,3 @@ | ||
it('should sanitize strings', function() { | ||
it('should sanitize strings', function () { | ||
try { | ||
@@ -268,3 +267,3 @@ var foo = new Logdown() | ||
// https://github.com/caiogondim/logdown/issues/14 | ||
xit('should print not-string arguments as is', function() { | ||
xit('should print not-string arguments as is', function () { | ||
try { | ||
@@ -271,0 +270,0 @@ var foo = new Logdown() |
/* global describe, it, beforeEach, afterEach, xit */ | ||
/* jshint node:true */ | ||
@@ -13,3 +12,3 @@ 'use strict' | ||
describe('NODE_DEBUG and DEBUG environment variables', function() { | ||
describe('NODE_DEBUG and DEBUG environment variables', function () { | ||
var sandbox | ||
@@ -21,7 +20,7 @@ // NODE_DEBUG is the official env var supported by Node | ||
beforeEach(function() { | ||
beforeEach(function () { | ||
sandbox = sinon.sandbox.create() | ||
sandbox.stub(global.console, 'log') | ||
envVars.forEach(function(envVar) { | ||
envVars.forEach(function (envVar) { | ||
process.env[envVar] = '' | ||
@@ -32,37 +31,37 @@ }) | ||
afterEach(function() { | ||
afterEach(function () { | ||
sandbox.restore() | ||
}) | ||
envVars.forEach(function(envVar) { | ||
envVars.forEach(function (envVar) { | ||
it('`' + envVar + '=foo` should enable only instances with “foo” prefix', | ||
function() { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
function () { | ||
try { | ||
var foo = new Logdown({prefix: 'foo'}) | ||
var bar = new Logdown({prefix: 'bar'}) | ||
var quz = new Logdown({prefix: 'quz'}) | ||
var baz = new Logdown({prefix: 'baz'}) | ||
process.env[envVar] = 'foo' | ||
process.env[envVar] = 'foo' | ||
bar.log('lorem') | ||
assert.notCalled(console.log) | ||
quz.log('lorem') | ||
assert.notCalled(console.log) | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.called(console.log) | ||
bar.log('lorem') | ||
assert.notCalled(console.log) | ||
quz.log('lorem') | ||
assert.notCalled(console.log) | ||
baz.log('lorem') | ||
assert.notCalled(console.log) | ||
foo.log('lorem') | ||
assert.called(console.log) | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
sandbox.restore() | ||
}) | ||
xit('`' + envVar + '=*foo` should enable only instances with names ' + | ||
'ending with “foo”', function() { | ||
'ending with “foo”', function () { | ||
try { | ||
@@ -93,3 +92,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
xit('`' + envVar + '=foo*` should enable only instances with names ' + | ||
'beginning with “foo”', function() { | ||
'beginning with “foo”', function () { | ||
try { | ||
@@ -119,3 +118,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`' + envVar + '=-*` should disable all instances', function() { | ||
it('`' + envVar + '=-*` should disable all instances', function () { | ||
try { | ||
@@ -143,3 +142,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`' + envVar + '=*,-foo` should enable all but only instances ' + | ||
'with “foo” prefix', function() { | ||
'with “foo” prefix', function () { | ||
try { | ||
@@ -168,3 +167,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`' + envVar + '=*,-*foo` should enable all but instances with names ' + | ||
'ending with “foo”', function() { | ||
'ending with “foo”', function () { | ||
try { | ||
@@ -193,3 +192,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`' + envVar + '=*,-foo*` should enable all but instances with names ' + | ||
'beginning with “foo”', function() { | ||
'beginning with “foo”', function () { | ||
try { | ||
@@ -217,3 +216,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
it('`' + envVar + '` should accept N arguments', function() { | ||
it('`' + envVar + '` should accept N arguments', function () { | ||
try { | ||
@@ -245,3 +244,3 @@ var foo = new Logdown({prefix: 'foo'}) | ||
// get the values in `NODE_DEBUG` | ||
it('`NODE_DEBUG` should have precedence over `DEBUG`', function() { | ||
it('`NODE_DEBUG` should have precedence over `DEBUG`', function () { | ||
try { | ||
@@ -248,0 +247,0 @@ var foo = new Logdown({prefix: 'foo'}) |
118990
18
32
2461