console-line-logger
Advanced tools
Comparing version 0.0.1 to 0.0.2
13
index.js
@@ -9,3 +9,8 @@ "use strict"; | ||
const throwingLine = stackLines[2]; | ||
const matches = throwingLine.match(/[^\(]+\((.*\.js)\:(\d+)\:(\d+)\)/); | ||
const matches = throwingLine.match(/[^\(\/]+\(?(.*\.js)\:(\d+)\:(\d+)\)?/); | ||
if(! matches) { | ||
return { | ||
throwingLine: colors.blue(throwingLine.trim()) | ||
}; | ||
} | ||
const fileName = path.relative(appRootDir, matches[1]); | ||
@@ -20,4 +25,6 @@ const lineNumber = parseInt(matches[2], 10); | ||
} catch(e) { | ||
const { fileName, lineNumber } = extractFilenameAndLine(e); | ||
console.log('\n' + colors.blue(fileName) + ':' + colors.red(lineNumber) + '\n', ...arguments); | ||
const { fileName, lineNumber, throwingLine } = extractFilenameAndLine(e); | ||
const str = throwingLine ? throwingLine : | ||
colors.blue(fileName) + ':' + colors.red(lineNumber); | ||
console.log('\n' + str + '\n', ...arguments); | ||
} | ||
@@ -24,0 +31,0 @@ } |
{ | ||
"name": "console-line-logger", | ||
"description": "console.log() that outputs file name and line number before args", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Benoit Hubert", |
1279
28