Socket
Socket
Sign inDemoInstall

pino-pretty

Package Overview
Dependencies
Maintainers
4
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-pretty - npm Package Compare versions

Comparing version 7.5.1 to 7.6.1

1

bin.js

@@ -38,2 +38,3 @@ #!/usr/bin/env node

.option(['X', 'customColors'], 'Override default colors using names from https://www.npmjs.com/package/colorette (`-X err:red,info:blue`)')
.option(['U', 'useOnlyCustomProps'], 'Only use custom levels and colors (if provided); don\'t fallback to default levels and colors (-U false)')
.option(['k', 'errorLikeObjectKeys'], 'Define which keys contain error objects (`-k err,error`) (defaults to `err,error`)')

@@ -40,0 +41,0 @@ .option(['m', 'messageKey'], 'Highlight the message under the specified key', CONSTANTS.MESSAGE_KEY)

@@ -11,6 +11,8 @@ // Type definitions for pino-pretty 7.0

import { OnUnknown } from 'pino-abstract-transport';
// @ts-ignore fall back to any if pino is not available, i.e. when running pino tests
import { DestinationStream } from 'pino';
type LogDescriptor = Record<string, unknown>;
declare function PinoPretty(options: PrettyOptions_): PinoPretty.PrettyStream;
declare function PinoPretty(options?: PrettyOptions_): PinoPretty.PrettyStream;

@@ -111,2 +113,17 @@ interface PrettyOptions_ {

/**
* The file, file descriptor, or stream to write to. Defaults to 1 (stdout).
* @default 1
*/
destination?: string | number | DestinationStream | NodeJS.WritableStream;
/**
* Opens the file with the 'a' flag.
* @default true
*/
append?: boolean;
/**
* Ensure directory for destination file exists.
* @default false
*/
mkdir?: boolean;
/**
* Provides the ability to add a custom prettify function for specific log properties.

@@ -113,0 +130,0 @@ * `customPrettifiers` is an object, where keys are log properties that will be prettified

33

index.js

@@ -7,5 +7,3 @@ 'use strict'

const abstractTransport = require('pino-abstract-transport')
const sonic = require('sonic-boom')
const sjs = require('secure-json-parse')
const colors = require('./lib/colors')

@@ -21,2 +19,3 @@ const { ERROR_LIKE_KEYS, MESSAGE_KEY, TIMESTAMP_KEY, LEVEL_KEY, LEVEL_NAMES } = require('./lib/constants')

prettifyTime,
buildSafeSonicBoom,
filterLog

@@ -40,2 +39,3 @@ } = require('./lib/utils')

customColors: null,
useOnlyCustomProps: true,
levelFirst: false,

@@ -65,2 +65,3 @@ messageKey: MESSAGE_KEY,

const errorProps = opts.errorProps.split(',')
const useOnlyCustomProps = typeof opts.useOnlyCustomProps === 'boolean' ? opts.useOnlyCustomProps : opts.useOnlyCustomProps === 'true'
const customLevels = opts.customLevels

@@ -76,3 +77,3 @@ ? opts.customLevels

}, { default: 'USERLVL' })
: undefined
: {}
const customLevelNames = opts.customLevels

@@ -84,7 +85,7 @@ ? opts.customLevels

agg[levelName] = levelIdx
agg[levelName.toLowerCase()] = levelIdx
return agg
}, {})
: undefined
: {}
const customColors = opts.customColors

@@ -96,3 +97,4 @@ ? opts.customColors

const levelNum = customLevelNames !== undefined ? customLevelNames[level] : LEVEL_NAMES[level]
const condition = useOnlyCustomProps ? opts.customLevels : customLevelNames[level] !== undefined
const levelNum = condition ? customLevelNames[level] : LEVEL_NAMES[level]
const colorIdx = levelNum !== undefined ? levelNum : level

@@ -105,2 +107,10 @@

: undefined
const customProps = {
customLevels,
customLevelNames
}
if (useOnlyCustomProps && !opts.customLevels) {
customProps.customLevels = undefined
customProps.customLevelNames = undefined
}
const customPrettifiers = opts.customPrettifiers

@@ -110,3 +120,3 @@ const ignoreKeys = opts.ignore ? new Set(opts.ignore.split(',')) : undefined

const singleLine = opts.singleLine
const colorizer = colors(opts.colorize, customColors)
const colorizer = colors(opts.colorize, customColors, useOnlyCustomProps)

@@ -129,3 +139,4 @@ return pretty

if (minimumLevel) {
const minimum = (customLevelNames === undefined ? LEVEL_NAMES[minimumLevel] : customLevelNames[minimumLevel]) || Number(minimumLevel)
const condition = useOnlyCustomProps ? opts.customLevels : customLevelNames[minimumLevel] !== undefined
const minimum = (condition ? customLevelNames[minimumLevel] : LEVEL_NAMES[minimumLevel]) || Number(minimumLevel)
const level = log[levelKey === undefined ? LEVEL_KEY : levelKey]

@@ -135,3 +146,3 @@ if (level < minimum) return

const prettifiedMessage = prettifyMessage({ log, messageKey, colorizer, messageFormat, levelLabel })
const prettifiedMessage = prettifyMessage({ log, messageKey, colorizer, messageFormat, levelLabel, ...customProps, useOnlyCustomProps })

@@ -142,3 +153,3 @@ if (ignoreKeys) {

const prettifiedLevel = prettifyLevel({ log, colorizer, levelKey, prettifier: customPrettifiers.level, customLevels, customLevelNames })
const prettifiedLevel = prettifyLevel({ log, colorizer, levelKey, prettifier: customPrettifiers.level, ...customProps })
const prettifiedMetadata = prettifyMetadata({ log, prettifiers: customPrettifiers })

@@ -242,3 +253,3 @@ const prettifiedTime = prettifyTime({ log, translateFormat: opts.translateTime, timestampKey, prettifier: customPrettifiers.time })

} else {
destination = sonic({
destination = buildSafeSonicBoom({
dest: opts.destination || 1,

@@ -245,0 +256,0 @@ append: opts.append,

@@ -45,35 +45,47 @@ 'use strict'

function colorizeLevel (level, colorizer, { customLevels, customLevelNames } = {}) {
const levels = customLevels || LEVELS
const levelNames = customLevelNames || LEVEL_NAMES
function colorizeLevel (useOnlyCustomProps) {
return function (level, colorizer, { customLevels, customLevelNames } = {}) {
const levels = useOnlyCustomProps ? customLevels || LEVELS : Object.assign({}, LEVELS, customLevels)
const levelNames = useOnlyCustomProps ? customLevelNames || LEVEL_NAMES : Object.assign({}, LEVEL_NAMES, customLevelNames)
let levelNum = 'default'
if (Number.isInteger(+level)) {
levelNum = Object.prototype.hasOwnProperty.call(levels, level) ? level : levelNum
} else {
levelNum = Object.prototype.hasOwnProperty.call(levelNames, level.toLowerCase()) ? levelNames[level.toLowerCase()] : levelNum
}
let levelNum = 'default'
if (Number.isInteger(+level)) {
levelNum = Object.prototype.hasOwnProperty.call(levels, level) ? level : levelNum
} else {
levelNum = Object.prototype.hasOwnProperty.call(levelNames, level.toLowerCase()) ? levelNames[level.toLowerCase()] : levelNum
}
const levelStr = levels[levelNum]
const levelStr = levels[levelNum]
return Object.prototype.hasOwnProperty.call(colorizer, levelNum) ? colorizer[levelNum](levelStr) : colorizer.default(levelStr)
return Object.prototype.hasOwnProperty.call(colorizer, levelNum) ? colorizer[levelNum](levelStr) : colorizer.default(levelStr)
}
}
function plainColorizer (level, opts) {
return colorizeLevel(level, plain, opts)
function plainColorizer (useOnlyCustomProps) {
const newPlainColorizer = colorizeLevel(useOnlyCustomProps)
const customColoredColorizer = function (level, opts) {
return newPlainColorizer(level, plain, opts)
}
customColoredColorizer.message = plain.message
customColoredColorizer.greyMessage = plain.greyMessage
return customColoredColorizer
}
plainColorizer.message = plain.message
plainColorizer.greyMessage = plain.greyMessage
function coloredColorizer (level, opts) {
return colorizeLevel(level, colored, opts)
function coloredColorizer (useOnlyCustomProps) {
const newColoredColorizer = colorizeLevel(useOnlyCustomProps)
const customColoredColorizer = function (level, opts) {
return newColoredColorizer(level, colored, opts)
}
customColoredColorizer.message = colored.message
customColoredColorizer.greyMessage = colored.greyMessage
return customColoredColorizer
}
coloredColorizer.message = colored.message
coloredColorizer.greyMessage = colored.greyMessage
function customColoredColorizerFactory (customColors) {
const customColored = resolveCustomColoredColorizer(customColors)
function customColoredColorizerFactory (customColors, useOnlyCustomProps) {
const onlyCustomColored = resolveCustomColoredColorizer(customColors)
const customColored = useOnlyCustomProps ? onlyCustomColored : Object.assign({}, colored, onlyCustomColored)
const colorizeLevelCustom = colorizeLevel(useOnlyCustomProps)
const customColoredColorizer = function (level, opts) {
return colorizeLevel(level, customColored, opts)
return colorizeLevelCustom(level, customColored, opts)
}

@@ -93,2 +105,3 @@ customColoredColorizer.message = customColoredColorizer.message || customColored.message

* @param {array[]} [customColors] Touple where first item of each array is the level index and the second item is the color
* @param {boolean} [useOnlyCustomProps] When `true`, only use the provided custom colors provided and not fallback to default
*

@@ -102,10 +115,10 @@ * @returns {function} `function (level) {}` has a `.message(str)` method to

*/
module.exports = function getColorizer (useColors = false, customColors) {
module.exports = function getColorizer (useColors = false, customColors, useOnlyCustomProps) {
if (useColors && customColors !== undefined) {
return customColoredColorizerFactory(customColors)
return customColoredColorizerFactory(customColors, useOnlyCustomProps)
} else if (useColors) {
return coloredColorizer
return coloredColorizer(useOnlyCustomProps)
}
return plainColorizer
return plainColorizer(useOnlyCustomProps)
}

@@ -5,3 +5,5 @@ 'use strict'

const dateformat = require('dateformat')
const SonicBoom = require('sonic-boom')
const stringifySafe = require('fast-safe-stringify')
const { isMainThread } = require('worker_threads')
const defaultColorizer = require('./colors')()

@@ -27,2 +29,3 @@ const {

prettifyTime,
buildSafeSonicBoom,
filterLog

@@ -257,3 +260,3 @@ }

*/
function prettifyMessage ({ log, messageFormat, messageKey = MESSAGE_KEY, colorizer = defaultColorizer, levelLabel = LEVEL_LABEL, levelKey = LEVEL_KEY, customLevels }) {
function prettifyMessage ({ log, messageFormat, messageKey = MESSAGE_KEY, colorizer = defaultColorizer, levelLabel = LEVEL_LABEL, levelKey = LEVEL_KEY, customLevels, useOnlyCustomProps }) {
if (messageFormat && typeof messageFormat === 'string') {

@@ -263,3 +266,4 @@ const message = String(messageFormat).replace(/{([^{}]+)}/g, function (match, p1) {

if (p1 === levelLabel && log[levelKey]) {
return customLevels === undefined ? LEVELS[log[levelKey]] : customLevels[log[levelKey]]
const condition = useOnlyCustomProps ? customLevels === undefined : customLevels[log[levelKey]] === undefined
return condition ? LEVELS[log[levelKey]] : customLevels[log[levelKey]]
}

@@ -587,1 +591,65 @@ // Parse nested key access, e.g. `{keyA.subKeyB}`.

}
function noop () {}
/**
* Creates a safe SonicBoom instance
*
* @param {object} opts Options for SonicBoom
*
* @returns {object} A new SonicBoom stream
*/
function buildSafeSonicBoom (opts) {
const stream = new SonicBoom(opts)
stream.on('error', filterBrokenPipe)
// if we are sync: false, we must flush on exit
if (!opts.sync && isMainThread) {
setupOnExit(stream)
}
return stream
function filterBrokenPipe (err) {
if (err.code === 'EPIPE') {
stream.write = noop
stream.end = noop
stream.flushSync = noop
stream.destroy = noop
return
}
stream.removeListener('error', filterBrokenPipe)
}
}
function setupOnExit (stream) {
/* istanbul ignore next */
if (global.WeakRef && global.WeakMap && global.FinalizationRegistry) {
// This is leak free, it does not leave event handlers
const onExit = require('on-exit-leak-free')
onExit.register(stream, autoEnd)
stream.on('close', function () {
onExit.unregister(stream)
})
}
}
/* istanbul ignore next */
function autoEnd (stream, eventName) {
// This check is needed only on some platforms
if (stream.destroyed) {
return
}
if (eventName === 'beforeExit') {
// We still have an event loop, let's use it
stream.flush()
stream.on('drain', function () {
stream.end()
})
} else {
// We do not have an event loop, so flush synchronously
stream.flushSync()
}
}
{
"name": "pino-pretty",
"version": "7.5.1",
"version": "7.6.1",
"description": "Prettifier for Pino log lines",

@@ -40,2 +40,3 @@ "type": "commonjs",

"joycon": "^3.1.1",
"on-exit-leak-free": "^0.2.0",
"pino-abstract-transport": "^0.5.0",

@@ -56,4 +57,4 @@ "pump": "^3.0.0",

"standard": "^16.0.3",
"tap": "^15.0.9",
"tsd": "^0.19.0",
"tap": "^16.0.0",
"tsd": "^0.20.0",
"typescript": "^4.4.3"

@@ -60,0 +61,0 @@ },

@@ -77,2 +77,5 @@ <a id="intro"></a>

- `--minimumLevel` (`-L`): Hide messages below the specified log level. Accepts a number, `trace`, `debug`, `info`, `warn`, `error`, or `fatal`. If any more filtering is required, consider using [`jq`](https://stedolan.github.io/jq/).
- `--customLevels` (`-x`): Override default levels with custom levels, e.g. `-x err:99,info:1`
- `--customColors` (`-X`): Override default colors with custom colors, e.g. `-X err:red,info:blue`
- `--useOnlyCustomProps` (`-U`): Only use custom levels and colors (if provided) (default: true); else fallback to default levels and colors, e.g. `-U false`
- `--messageFormat` (`-o`): Format output of message, e.g. `{levelLabel} - {pid} - url:{request.url}` will output message: `INFO - 1123 - url:localhost:3000/test`

@@ -256,3 +259,3 @@ Default: `false`

append: true, // the file is opened with the 'a' flag
mdkdir: true, // create the target destination
mkdir: true, // create the target destination

@@ -267,2 +270,5 @@

The defaults for `sync`, `append`, `mkdir` inherit from
[`SonicBoom(opts)`](https://github.com/pinojs/sonic-boom#API).
`customPrettifiers` option provides the ability to add a custom prettify function

@@ -342,5 +348,16 @@ for specific log properties. `customPrettifiers` is an object, where keys are

<a id="license"><a>
## Limitations
Because `pino-pretty` uses stdout redirection, in some cases the command may
terminate with an error due to shell limitations.
For example, currently, mingw64 based shells (e.g. Bash as supplied by [git for
Windows](https://gitforwindows.org)) are affected and terminate the process with
a `stdout is not a tty` error message.
Any PRs are welcomed!
<a id="license"></a>
## License
MIT License

@@ -311,2 +311,3 @@ 'use strict'

const localHour = dateformat(epoch, 'HH')
const localMinute = dateformat(epoch, 'MM')
const localDate = dateformat(epoch, 'yyyy-mm-dd')

@@ -316,3 +317,3 @@ const offset = dateformat(epoch, 'o')

formatted,
`[${localDate} ${localHour}:35:28.992 ${offset}] INFO (${pid} on ${hostname}): foo\n`
`[${localDate} ${localHour}:${localMinute}:28.992 ${offset}] INFO (${pid} on ${hostname}): foo\n`
)

@@ -334,2 +335,3 @@ cb()

const localHour = dateformat(epoch, 'HH')
const localMinute = dateformat(epoch, 'MM')
const localDate = dateformat(epoch, 'yyyy/mm/dd')

@@ -339,3 +341,3 @@ const offset = dateformat(epoch, 'o')

formatted,
`[${localDate} ${localHour}:35:28 ${offset}] INFO (${pid} on ${hostname}): foo\n`
`[${localDate} ${localHour}:${localMinute}:28 ${offset}] INFO (${pid} on ${hostname}): foo\n`
)

@@ -342,0 +344,0 @@ cb()

@@ -99,2 +99,26 @@ 'use strict'

})
t.test(`customize levels via ${optionName} with minimumLevel, customLevels and useOnlyCustomProps false`, (t) => {
t.plan(1)
const child = spawn(process.argv[0], [bin, '--minimumLevel', 'custom', '--useOnlyCustomProps', 'false', optionName, 'custom:99,info:1'], { env })
child.on('error', t.threw)
child.stdout.on('data', (data) => {
t.equal(data.toString(), `[${epoch}] CUSTOM (42 on foo): hello world\n`)
})
child.stdin.write('{"level":1,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo"}\n')
child.stdin.write('{"level":99,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo"}\n')
t.teardown(() => child.kill())
})
t.test(`customize levels via ${optionName} with minimumLevel, customLevels and useOnlyCustomProps true`, (t) => {
t.plan(1)
const child = spawn(process.argv[0], [bin, '--minimumLevel', 'custom', '--useOnlyCustomProps', 'true', optionName, 'custom:99,info:1'], { env })
child.on('error', t.threw)
child.stdout.on('data', (data) => {
t.equal(data.toString(), `[${epoch}] CUSTOM (42 on foo): hello world\n`)
})
child.stdin.write('{"level":1,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo"}\n')
child.stdin.write('{"level":99,"time":1522431328992,"msg":"hello world","pid":42,"hostname":"foo"}\n')
t.teardown(() => child.kill())
})
})

@@ -127,2 +151,70 @@

;['--useOnlyCustomProps', '-U'].forEach((optionName) => {
t.test(`customize levels via ${optionName} false and customColors`, (t) => {
t.plan(1)
const child = spawn(process.argv[0], [bin, '--customColors', 'err:blue,info:red', optionName, 'false'], { env })
child.on('error', t.threw)
child.stdout.on('data', (data) => {
t.equal(data.toString(), `[${epoch}] INFO (42 on foo): hello world\n`)
})
child.stdin.write(logLine)
t.teardown(() => child.kill())
})
t.test(`customize levels via ${optionName} true and customColors`, (t) => {
t.plan(1)
const child = spawn(process.argv[0], [bin, '--customColors', 'err:blue,info:red', optionName, 'true'], { env })
child.on('error', t.threw)
child.stdout.on('data', (data) => {
t.equal(data.toString(), `[${epoch}] INFO (42 on foo): hello world\n`)
})
child.stdin.write(logLine)
t.teardown(() => child.kill())
})
t.test(`customize levels via ${optionName} true and customLevels`, (t) => {
t.plan(1)
const child = spawn(process.argv[0], [bin, '--customLevels', 'err:99,custom:30', optionName, 'true'], { env })
child.on('error', t.threw)
child.stdout.on('data', (data) => {
t.equal(data.toString(), `[${epoch}] CUSTOM (42 on foo): hello world\n`)
})
child.stdin.write(logLine)
t.teardown(() => child.kill())
})
t.test(`customize levels via ${optionName} true and no customLevels`, (t) => {
t.plan(1)
const child = spawn(process.argv[0], [bin, optionName, 'true'], { env })
child.on('error', t.threw)
child.stdout.on('data', (data) => {
t.equal(data.toString(), `[${epoch}] INFO (42 on foo): hello world\n`)
})
child.stdin.write(logLine)
t.teardown(() => child.kill())
})
t.test(`customize levels via ${optionName} false and customLevels`, (t) => {
t.plan(1)
const child = spawn(process.argv[0], [bin, '--customLevels', 'err:99,custom:25', optionName, 'false'], { env })
child.on('error', t.threw)
child.stdout.on('data', (data) => {
t.equal(data.toString(), `[${epoch}] INFO (42 on foo): hello world\n`)
})
child.stdin.write(logLine)
t.teardown(() => child.kill())
})
t.test(`customize levels via ${optionName} false and no customLevels`, (t) => {
t.plan(1)
const child = spawn(process.argv[0], [bin, optionName, 'false'], { env })
child.on('error', t.threw)
child.stdout.on('data', (data) => {
t.equal(data.toString(), `[${epoch}] INFO (42 on foo): hello world\n`)
})
child.stdin.write(logLine)
t.teardown(() => child.kill())
})
})
t.test('does ignore escaped keys', (t) => {

@@ -129,0 +221,0 @@ t.plan(1)

@@ -99,2 +99,3 @@ 'use strict'

const colorizer = getColorizer(true, customColors)
const colorizerWithCustomPropUse = getColorizer(true, customColors, true)
let colorized = colorizer(1, opts)

@@ -117,2 +118,8 @@ t.equal(colorized, '\u001B[31mERR\u001B[39m')

t.equal(colorized, '\u001B[37mUSERLVL\u001B[39m')
colorized = colorizer(40, opts)
t.equal(colorized, '\u001B[33mWARN\u001B[39m')
colorized = colorizerWithCustomPropUse(50, opts)
t.equal(colorized, '\u001B[37mUSERLVL\u001B[39m')
}

@@ -119,0 +126,0 @@

@@ -6,2 +6,5 @@ 'use strict'

const utils = require('../../lib/utils')
const rimraf = require('rimraf')
const { join } = require('path')
const fs = require('fs')

@@ -105,7 +108,12 @@ tap.test('prettifyErrorLog', t => {

t.test('returns message formatted by `messageFormat` option - levelLabel', async t => {
const str = prettifyMessage({ log: { msg: 'foo', context: 'appModule', level: 30 }, messageFormat: '[{level}] {levelLabel} {context} - {msg}' })
t.test('returns message formatted by `messageFormat` option - levelLabel & useOnlyCustomProps false', async t => {
const str = prettifyMessage({ log: { msg: 'foo', context: 'appModule', level: 30 }, messageFormat: '[{level}] {levelLabel} {context} - {msg}', customLevels: {} })
t.equal(str, '[30] INFO appModule - foo')
})
t.test('returns message formatted by `messageFormat` option - levelLabel & useOnlyCustomProps true', async t => {
const str = prettifyMessage({ log: { msg: 'foo', context: 'appModule', level: 30 }, messageFormat: '[{level}] {levelLabel} {context} - {msg}', customLevels: { 30: 'CHECK' }, useOnlyCustomProps: true })
t.equal(str, '[30] CHECK appModule - foo')
})
t.test('returns message formatted by `messageFormat` option - levelLabel & customLevels', async t => {

@@ -116,2 +124,12 @@ const str = prettifyMessage({ log: { msg: 'foo', context: 'appModule', level: 123 }, messageFormat: '[{level}] {levelLabel} {context} - {msg}', customLevels: { 123: 'CUSTOM' } })

t.test('returns message formatted by `messageFormat` option - levelLabel, customLevels & useOnlyCustomProps', async t => {
const str = prettifyMessage({ log: { msg: 'foo', context: 'appModule', level: 123 }, messageFormat: '[{level}] {levelLabel} {context} - {msg}', customLevels: { 123: 'CUSTOM' }, useOnlyCustomProps: true })
t.equal(str, '[123] CUSTOM appModule - foo')
})
t.test('returns message formatted by `messageFormat` option - levelLabel, customLevels & useOnlyCustomProps false', async t => {
const str = prettifyMessage({ log: { msg: 'foo', context: 'appModule', level: 40 }, messageFormat: '[{level}] {levelLabel} {context} - {msg}', customLevels: { 123: 'CUSTOM' }, useOnlyCustomProps: false })
t.equal(str, '[40] WARN appModule - foo')
})
t.test('`messageFormat` supports nested curly brackets', async t => {

@@ -434,1 +452,46 @@ const str = prettifyMessage({ log: { level: 30 }, messageFormat: '{{level}}-{level}-{{level}-{level}}' })

})
tap.test('buildSafeSonicBoom', t => {
const { buildSafeSonicBoom } = utils
function noop () {}
const file = () => {
const dest = join(__dirname, `${process.pid}-${process.hrtime().toString()}`)
const fd = fs.openSync(dest, 'w')
return { dest, fd }
}
t.test('should not write when error emitted and code is "EPIPE"', async t => {
t.plan(1)
const { fd, dest } = file()
const stream = buildSafeSonicBoom({ sync: true, fd, mkdir: true })
t.teardown(() => rimraf(dest, noop))
stream.emit('error', { code: 'EPIPE' })
stream.write('will not work')
const dataFile = fs.readFileSync(dest)
t.equal(dataFile.length, 0)
})
t.test('should stream.write works when error code is not "EPIPE"', async t => {
t.plan(3)
const { fd, dest } = file()
const stream = buildSafeSonicBoom({ sync: true, fd, mkdir: true })
t.teardown(() => rimraf(dest, noop))
stream.on('error', () => t.pass('error emitted'))
stream.emit('error', 'fake error description')
t.ok(stream.write('will work'))
const dataFile = fs.readFileSync(dest)
t.equal(dataFile.toString(), 'will work')
})
t.end()
})

@@ -32,2 +32,5 @@ import { expectType } from "tsd";

sync: false,
destination: 2,
append: true,
mkdir: true,
};

@@ -56,4 +59,8 @@

sync: false,
destination: 2,
append: true,
mkdir: true,
};
expectType<PrettyStream>(pretty()); // #326
expectType<PrettyStream>(pretty(options));

@@ -60,0 +67,0 @@ expectType<PrettyStream>(PinoPrettyNamed(options));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc