Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove source-map-support package in favor of native NodeJS support #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

require('source-map-support/register')
const NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10)
const STACKTRACE_OFFSET = NODEJS_VERSION && NODEJS_VERSION > 6 ? 0 : 1
const LINE_OFFSET = 7
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,27 @@
"standard": "^8.6.0",
"tap": "^12.0.1",
"through2": "^4.0.2",
"tsd": "^0.28.0",
"ts-node": "^10.2.1",
"tsd": "^0.28.0",
"typescript": "^5.0.2"
},
"peerDependencies": {
"pino": "*"
},
"engines": {
"node": ">6.0.0"
"node": ">=12.12.0"
},
"scripts": {
"lint-fix": "standard --fix index.js examples/*js tests/*.js",
"pretest": "npm run lint-fix",
"test": "tap tests/*.js && npm run test-ts && npm run test-types",
"test-ts": "ts-node tests/test-ts.ts",
"test-watch": "tap tests/*.js tests/*.ts",
"test:ci": "npm run pretest && tap --node-arg=\"-r\" --node-arg=\"source-map-support/register\" tests/*.js tests/*.ts --coverage-report=lcovonly && npm run test-types",
"test:ci": "npm run pretest && tap --node-arg=\"--enable-source-maps\" tests/*.js tests/*.ts --coverage-report=lcovonly && npm run test-types",
"test-types": "tsc && tsd",
"example": "env NODE_ENV=development node examples/index.js",
"watch": "npm-watch"
},
"dependencies": {
"source-map-support": "^0.5.13"
},
"standard": {
"ignore": [
"examples/module-ts.js"
Expand Down
16 changes: 16 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,19 @@ test('pino caller can make stack adjustments', function(t) {
}
log.info('test')
})

test('pino caller stack trace line number maps correctly', function (t) {
t.plan(4)

const pinoInstance = pinoCaller(pino(through2(function (chunk, enc, callback) {
const res = JSON.parse(chunk.toString('utf8'))
const regex = /Test.<anonymous> \(\/(?:.)*tests\/test.js:(\d+)/
const matches = regex.exec(res.caller || '')
t.ok(res.caller, 'caller property is set')
t.equal(typeof res.caller, 'string', 'caller property is a string')
t.ok(matches, 'caller property matches the test regex')
t.ok(parseInt(matches[1], 10) > 1, 'line number in stack trace is greater than 1')
})))

pinoInstance.fatal('test')
})
Loading