console-stamp
Advanced tools
Comparing version 3.1.1 to 3.1.2
@@ -49,8 +49,11 @@ const df = require( './defaults' ); | ||
prefix = prefix.replace( re, ( match, params ) => { | ||
let ret = token( { method, defaultTokens, params: parseParams( params ), tokens, msg } ); | ||
match.replace( params, '' ).split( '.' ).slice( 1 ).forEach( decorator => { | ||
ret = chalk`{${decorator} ${ret}}`; | ||
} ); | ||
return ret; | ||
try { | ||
let ret = token({method, defaultTokens, params: parseParams(params), tokens, msg}); | ||
match.replace(params, '').split('.').slice(1).forEach(decorator => { | ||
ret = chalk`{${decorator} ${ret}}`; | ||
}); | ||
return ret; | ||
}catch (e){ | ||
return match; | ||
} | ||
} ); | ||
@@ -61,9 +64,17 @@ } ); | ||
const rec = /(\([^)]*\))(\.\w+)+/g; | ||
prefix = prefix.replace( rec, ( match, text ) => { | ||
let ret = text.replace( /[\(\)]/g, '' ); | ||
match.replace( text, '' ).split( '.' ).slice( 1 ).forEach( decorator => { | ||
ret = chalk`{${decorator} ${ret}}`; | ||
} ); | ||
return ret; | ||
} ) | ||
if(/(\([^)]*\))(\.\w+)/.test(prefix.replace(msg,''))){ // If there is a color group in the prefix | ||
prefix = prefix.replace(rec, (match, text) => { | ||
try { | ||
let ret = text.replace(/[()]/g, ''); | ||
match.replace(text, '').split('.').slice(1).forEach(decorator => { | ||
ret = chalk`{${decorator} ${ret}}`; | ||
}); | ||
return ret; | ||
} catch (e) { | ||
return match; | ||
} | ||
}); | ||
} | ||
return prefix; | ||
@@ -70,0 +81,0 @@ } |
{ | ||
"name": "console-stamp", | ||
"main": "index.js", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "test": "tap --no-check-coverage -R spec test/*.js", |
20318
206