Skip to content

Commit

Permalink
fix: bind fetch output to log()
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 3, 2022
1 parent 38e95cf commit 6fe3031
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/goods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { setTimeout as sleep } from 'node:timers/promises'
import nodeFetch, { RequestInfo, RequestInit } from 'node-fetch'
import { getCtx, getRootCtx } from './context.js'
import { colorize } from './print.js'
import { log } from './print.js'

export { default as chalk } from 'chalk'
export { default as fs } from 'fs-extra'
Expand All @@ -40,13 +41,13 @@ globbyModule)
export const glob = globby

export async function fetch(url: RequestInfo, init?: RequestInit) {
if (getCtx().verbose) {
if (typeof init !== 'undefined') {
console.log('$', colorize(`fetch ${url}`), init)
} else {
console.log('$', colorize(`fetch ${url}`))
}
}
log(
{ scope: 'fetch' },
'$',
colorize(`fetch ${url}`),
init && JSON.stringify(init, null, 2)
)

return nodeFetch(url, init)
}

Expand Down

0 comments on commit 6fe3031

Please sign in to comment.