Comparing version 7.6.0 to 7.6.1
'use strict' | ||
const fs = require('fs') | ||
function noOpPrepareStackTrace (_, stack) { | ||
@@ -7,2 +9,6 @@ return stack | ||
function isOutsideNodeModules (input) { | ||
return typeof input === 'string' && fs.existsSync(input) && input.indexOf('node_modules') === -1 | ||
} | ||
module.exports = function getCaller () { | ||
@@ -18,9 +24,13 @@ const originalPrepare = Error.prepareStackTrace | ||
for (const entry of stack.slice(2)) { | ||
const entries = stack.slice(2) | ||
for (const entry of entries) { | ||
const file = entry ? entry.getFileName() : undefined | ||
if (file && file.indexOf('node_modules') === -1) { | ||
if (isOutsideNodeModules(file)) { | ||
return file | ||
} | ||
} | ||
return entries[0] ? entries[0].getFileName() : undefined | ||
} |
{ | ||
"name": "pino", | ||
"version": "7.6.0", | ||
"version": "7.6.1", | ||
"description": "super fast, all natural json logger", | ||
@@ -5,0 +5,0 @@ "main": "pino.js", |
@@ -10,4 +10,4 @@ 'use strict' | ||
test('app using a custom transport', async function (t) { | ||
const evalApp = join(__dirname, '../', '/fixtures/eval') | ||
test('when using a custom transport outside node_modules, the first file outside node_modules should be used', async function (t) { | ||
const evalApp = join(__dirname, '../', '/fixtures/eval/index.js') | ||
const child = execa(process.argv[0], [evalApp]) | ||
@@ -25,1 +25,31 @@ | ||
}) | ||
test('when using a custom transport where some files in stacktrace are in the node_modules, the first file outside node_modules should be used', async function (t) { | ||
const evalApp = join(__dirname, '../', '/fixtures/eval/node_modules/2-files.js') | ||
const child = execa(process.argv[0], [evalApp]) | ||
let actual = '' | ||
child.stdout.pipe(writer((s, enc, cb) => { | ||
actual += s | ||
cb() | ||
})) | ||
await once(child, 'close') | ||
t.match(actual, /done!/) | ||
}) | ||
test('when using a custom transport where all files in stacktrace are in the node_modules, the first file inside node_modules should be used', async function (t) { | ||
const evalApp = join(__dirname, '../', '/fixtures/eval/node_modules/14-files.js') | ||
const child = execa(process.argv[0], [evalApp]) | ||
let actual = '' | ||
child.stdout.pipe(writer((s, enc, cb) => { | ||
actual += s | ||
cb() | ||
})) | ||
await once(child, 'close') | ||
t.match(actual, /done!/) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
458674
143
11037
48