Skip to content

Commit

Permalink
fix: add debug logs to config resolution (#5162)
Browse files Browse the repository at this point in the history
  • Loading branch information
JGAntunes authored Oct 12, 2022
1 parent dc75103 commit 10c175a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/commands/base-command.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const {
pollForToken,
sortOptions,
track,
warn,
} = require('../utils/index.cjs')

// Netlify CLI client id. Lives in bot@netlify.com
Expand Down Expand Up @@ -497,6 +498,10 @@ class BaseCommand extends Command {
// @todo Replace this with a mechanism for calling `resolveConfig` with more granularity (i.e. having
// the option to say that we don't need API data.)
if (isUserError && !offline && token) {
if (this.opts().debug) {
error(error_, { exit: false })
warn('Failed to resolve config, falling back to offline resolution')
}
return this.getConfig({ cwd, offline: true, state, token })
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/command-helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const error = (message = '', options = {}) => {
if (options.exit === false) {
const bang = chalk.red(BANG)
if (process.env.DEBUG) {
process.stderr.write(` ${bang} Warning: ${err.stack.split('\n').join(`\n ${bang} `)}`)
process.stderr.write(` ${bang} Warning: ${err.stack.split('\n').join(`\n ${bang} `)}\n`)
} else {
process.stderr.write(` ${bang} ${chalk.red(`${err.name}:`)} ${err.message}\n`)
}
Expand Down

1 comment on commit 10c175a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 230 MB

Please sign in to comment.