Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
missing esm style import
  • Loading branch information
Cangit committed Jul 11, 2024
commit bd927b3c73c7ed59eaf99f8cd5d31480caf57c74
6 changes: 3 additions & 3 deletions docs/transports.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ flushed as quickly as possible (there is nothing to do).
A transport is a module that exports a default function that returns a writable stream:

```js
import { createWriteStream } from 'fs'
import { createWriteStream } from 'node:fs'

export default (options) => {
return createWriteStream(options.destination)
Expand Down Expand Up @@ -54,7 +54,7 @@ The exported function can also be async. If we use an async function we can thro
if the transform could not be opened. As an example:

```js
import fs from 'fs'
import fs from 'node:fs'
import { once } from 'events'
export default async (options) => {
const stream = fs.createWriteStream(options.destination)
Expand Down Expand Up @@ -218,7 +218,7 @@ As an example, the following transport returns a `Transform` stream:

```js
import build from 'pino-abstract-transport'
import { pipeline, Transform } from 'stream'
import { pipeline, Transform } from 'node:stream'
export default async function (options) {
return build(function (source) {
const myTransportStream = new Transform({
Expand Down
2 changes: 1 addition & 1 deletion lib/transport-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = loadTransportStreamBuilder
/**
* Loads & returns a function to build transport streams
* @param {string} target
* @returns {function(object): Promise<import('stream').Writable>}
* @returns {function(object): Promise<import('node:stream').Writable>}
* @throws {Error} In case the target module does not export a function
*/
async function loadTransportStreamBuilder (target) {
Expand Down
5 changes: 2 additions & 3 deletions test/esm/named-exports.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { tmpdir, hostname } from 'os'
import { hostname } from 'node:os'
import t from 'tap'
import { sink, check, once, watchFileCreated, file } from '../helper.js'
import { pino, destination } from '../../pino.js'
import { join } from 'path'
import { readFileSync } from 'fs'
import { readFileSync } from 'node:fs'

t.test('named exports support', async ({ equal }) => {
const stream = sink()
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/to-file-transport.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createWriteStream } from 'fs'
import { once } from 'events'
import { createWriteStream } from 'node:fs'
import { once } from 'node:events'

export default async function run (opts) {
const stream = createWriteStream(opts.destination)
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/ts/to-file-transport-with-transform.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs'
import { once } from 'events'
import { Transform } from 'stream'
import * as fs from 'node:fs'
import { once } from 'node:events'
import { Transform } from 'node:stream'

async function run (opts: { destination?: fs.PathLike }): Promise<Transform> {
if (!opts.destination) throw new Error('kaboom')
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/ts/to-file-transport.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'fs'
import { once } from 'events'
import * as fs from 'node:fs'
import { once } from 'node:events'

async function run (opts: { destination?: fs.PathLike }): Promise<fs.WriteStream> {
if (!opts.destination) throw new Error('kaboom')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pino from '../../..'
import { join } from 'path'
import { join } from 'node:path'

const transport = pino.transport({
target: join(__dirname, 'to-file-transport-with-transform.ts'),
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/ts/transport-main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'path'
import { join } from 'node:path'
import pino from '../../..'

const transport = pino.transport({
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/ts/transport-worker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Writable } from 'stream'
import { Writable } from 'node:stream'

export default (): Writable => {
const myTransportStream = new Writable({
Expand Down
2 changes: 1 addition & 1 deletion test/helper.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PathLike } from 'fs'
import { PathLike } from 'node:fs'

export declare function watchFileCreated(filename: PathLike): Promise<void>
export declare function watchForWrite(filename: PathLike, testString: string): Promise<void>
10 changes: 5 additions & 5 deletions test/transport/core.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as os from 'os'
import { join } from 'path'
import { once } from 'events'
import fs from 'fs'
import * as os from 'node:os'
import { join } from 'node:path'
import { once } from 'node:events'
import fs from 'node:fs'
import { watchFileCreated } from '../helper'
import { test } from 'tap'
import pino from '../../'
import * as url from 'url'
import * as url from 'node:url'
import { default as strip } from 'strip-ansi'
import execa from 'execa'
import writer from 'flush-write-stream'
Expand Down
12 changes: 4 additions & 8 deletions test/transport/core.transpiled.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as os from 'os'
import { join } from 'path'
import { once } from 'events'
import fs from 'fs'
import * as os from 'node:os'
import { join } from 'node:path'
import fs from 'node:fs'
import { watchFileCreated } from '../helper'
import { test } from 'tap'
import pino from '../../'
import * as url from 'url'
import { default as strip } from 'strip-ansi'
import execa from 'execa'
import writer from 'flush-write-stream'
import * as url from 'node:url'

const readFile = fs.promises.readFile

Expand Down
2 changes: 1 addition & 1 deletion test/types/pino-multistream.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expectType } from 'tsd'

import { createWriteStream } from 'fs'
import { createWriteStream } from 'node:fs'

import pino, { multistream } from '../../pino'

Expand Down
4 changes: 2 additions & 2 deletions test/types/pino.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StreamEntry, pino } from '../../pino'
import { join } from 'path'
import { tmpdir } from 'os'
import { join } from 'node:path'
import { tmpdir } from 'node:os'
import pinoPretty from 'pino-pretty'

const destination = join(
Expand Down