Skip to content

Commit

Permalink
fix pino-pretty test
Browse files Browse the repository at this point in the history
  • Loading branch information
Eomm committed Sep 7, 2021
1 parent ae5a43f commit 72298d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/package-manager-ci.yml
Expand Up @@ -48,8 +48,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Use yarn
run: |
npm install -g yarn
yarn set version berry && yarn set version 2.4.2
yarn set version berry && yarn set version 2
echo "nodeLinker: node-modules" >> .yarnrc.yml
# see https://github.com/yarnpkg/berry/issues/2935#issuecomment-911299992
yarn add --dev typescript@~4.3.2
Expand All @@ -76,7 +75,6 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Use yarn
run: |
npm install -g yarn
yarn set version berry
echo 'nodeLinker: pnp
packageExtensions:
Expand Down
15 changes: 13 additions & 2 deletions lib/worker.js
Expand Up @@ -10,8 +10,19 @@ const build = require('pino-abstract-transport')

module.exports = async function ({ targets }) {
targets = await Promise.all(targets.map(async (t) => {
const toLoad = 'file://' + t.target
const stream = await (await import(toLoad)).default(t.options)
let fn
try {
const toLoad = 'file://' + t.target
fn = (await import(toLoad)).default
} catch (error) {
// See this PR for details: https://github.com/pinojs/thread-stream/pull/34
if ((error.code === 'ENOTDIR' || error.code === 'ERR_MODULE_NOT_FOUND')) {
fn = require(t.target)
} else {
throw error
}
}
const stream = await fn(t.options)
return {
level: t.level,
stream
Expand Down

0 comments on commit 72298d3

Please sign in to comment.