diff --git a/index.js b/index.js index 3ac3c8bd..ab76d336 100644 --- a/index.js +++ b/index.js @@ -62,40 +62,40 @@ function prettyFactory (options) { const useOnlyCustomProps = typeof opts.useOnlyCustomProps === 'boolean' ? opts.useOnlyCustomProps : opts.useOnlyCustomProps === 'true' const customLevels = opts.customLevels ? opts.customLevels - .split(',') - .reduce((agg, value, idx) => { - const [levelName, levelIdx = idx] = value.split(':') + .split(',') + .reduce((agg, value, idx) => { + const [levelName, levelIdx = idx] = value.split(':') - agg[levelIdx] = levelName.toUpperCase() + agg[levelIdx] = levelName.toUpperCase() - return agg - }, { default: 'USERLVL' }) + return agg + }, { default: 'USERLVL' }) : {} const customLevelNames = opts.customLevels ? opts.customLevels - .split(',') - .reduce((agg, value, idx) => { - const [levelName, levelIdx = idx] = value.split(':') + .split(',') + .reduce((agg, value, idx) => { + const [levelName, levelIdx = idx] = value.split(':') - agg[levelName.toLowerCase()] = levelIdx + agg[levelName.toLowerCase()] = levelIdx - return agg - }, {}) + return agg + }, {}) : {} const customColors = opts.customColors ? opts.customColors - .split(',') - .reduce((agg, value) => { - const [level, color] = value.split(':') + .split(',') + .reduce((agg, value) => { + const [level, color] = value.split(':') - const condition = useOnlyCustomProps ? opts.customLevels : customLevelNames[level] !== undefined - const levelNum = condition ? customLevelNames[level] : LEVEL_NAMES[level] - const colorIdx = levelNum !== undefined ? levelNum : level + const condition = useOnlyCustomProps ? opts.customLevels : customLevelNames[level] !== undefined + const levelNum = condition ? customLevelNames[level] : LEVEL_NAMES[level] + const colorIdx = levelNum !== undefined ? levelNum : level - agg.push([colorIdx, color]) + agg.push([colorIdx, color]) - return agg - }, []) + return agg + }, []) : undefined const customProps = { customLevels, diff --git a/package.json b/package.json index 0e427344..803d7ea5 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "colorette": "^2.0.7", "dateformat": "^4.6.3", "fast-copy": "^2.1.1", - "fast-safe-stringify": "^2.0.7", + "fast-safe-stringify": "^2.1.1", "joycon": "^3.1.1", "on-exit-leak-free": "^1.0.0", "pino-abstract-transport": "^0.5.0", @@ -48,11 +48,11 @@ }, "devDependencies": { "@types/node": "^17.0.0", - "pino": "^7.0.0", + "pino": "^8.0.0", "pre-commit": "^1.2.2", "rimraf": "^3.0.2", "snazzy": "^9.0.0", - "standard": "^16.0.3", + "standard": "^17.0.0", "tap": "^16.0.0", "tsd": "^0.20.0", "typescript": "^4.4.3" diff --git a/test/basic.test.js b/test/basic.test.js index 1c6c5e3c..710cb361 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -377,8 +377,8 @@ test('basic prettifier tests', (t) => { const opts = { base: { - name: name, - hostname: hostname + name, + hostname } } const log = pino(opts, new Writable({ @@ -401,7 +401,7 @@ test('basic prettifier tests', (t) => { const opts = { base: { - name: name, + name, pid: process.pid } } @@ -424,7 +424,7 @@ test('basic prettifier tests', (t) => { const opts = { base: { - hostname: hostname, + hostname, pid: process.pid } } diff --git a/test/cli-rc.test.js b/test/cli-rc.test.js index fb2a5615..2f247979 100644 --- a/test/cli-rc.test.js +++ b/test/cli-rc.test.js @@ -186,7 +186,10 @@ test('cli', (t) => { const child = spawn(process.argv[0], args, { env, cwd: tmpDir }) child.on('close', (code) => t.equal(code, 1)) child.stderr.on('data', (data) => { - t.equal(data.indexOf('Error: Failed to load runtime configuration file: pino-pretty.config.missing.json') >= 0, true) + t.equal( + data.toString().indexOf('Error: Failed to load runtime configuration file: pino-pretty.config.missing.json') >= 0, + true + ) }) t.teardown(() => child.kill()) }) diff --git a/test/error-objects.test.js b/test/error-objects.test.js index 711e5627..1d6c4b34 100644 --- a/test/error-objects.test.js +++ b/test/error-objects.test.js @@ -423,10 +423,11 @@ test('error like objects tests', { only: true }, (t) => { t.test('handles errors with a null stack for Error object', (t) => { const pretty = prettyFactory() const expectedLines = [ - '"type": "Error"', - '"message": "error message"', - '"stack": null', - '"some": "property"' + ' "type": "Error",', + ' "message": "error message",', + ' "stack":', + ' ', + ' "some": "property"' ] t.plan(expectedLines.length) const log = pino({}, new Writable({ diff --git a/test/lib/utils.public.test.js b/test/lib/utils.public.test.js index 693595df..14ff9240 100644 --- a/test/lib/utils.public.test.js +++ b/test/lib/utils.public.test.js @@ -408,7 +408,7 @@ tap.test('#filterLog', t => { t.test('filterLog keeps error instance', async t => { const result = filterLog(logData, []) - t.equals(logData.data1.error, result.data1.error) + t.equal(logData.data1.error, result.data1.error) }) const logData2 = Object.assign({