Skip to content

Commit

Permalink
fix(recipes): Don't write out debug log unless env var is set (#23169)
Browse files Browse the repository at this point in the history
  • Loading branch information
johno authored Apr 16, 2020
1 parent 37bf95e commit 82ee210
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/gatsby-recipes/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,15 @@ const components = {
NPMScript: () => null,
}

var logStream = fs.createWriteStream(`recipe-client.log`, { flags: `a` })
let logStream
const log = (label, textOrObj) => {
logStream.write(`[${label}]:\n`)
logStream.write(require(`util`).inspect(textOrObj))
logStream.write(`\n`)
if (process.env.DEBUG) {
logStream =
logStream ?? fs.createWriteStream(`recipe-client.log`, { flags: `a` })
logStream.write(`[${label}]:\n`)
logStream.write(require(`util`).inspect(textOrObj))
logStream.write(`\n`)
}
}

log(
Expand Down

0 comments on commit 82ee210

Please sign in to comment.