Skip to content

Commit

Permalink
fix(gatsby): only enable debugger when argument is given (#26669)
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Aug 31, 2020
1 parent 7e83ace commit 93fdc09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions packages/gatsby-cli/src/create-cli.ts
Expand Up @@ -175,17 +175,23 @@ function buildLocalCommands(cli: yargs.Argv, isLocalSite: boolean): void {
.option(`inspect`, {
type: `number`,
describe: `Opens a port for debugging. See https://www.gatsbyjs.org/docs/debugging-the-build-process/`,
default: 9229,
})
.option(`inspect-brk`, {
type: `number`,
describe: `Opens a port for debugging. Will block until debugger is attached. See https://www.gatsbyjs.org/docs/debugging-the-build-process/`,
default: 9229,
}),
handler: handlerP(
getCommandHandler(`develop`, (args: yargs.Arguments, cmd: Function) => {
process.env.NODE_ENV = process.env.NODE_ENV || `development`
startGraphQLServer(siteInfo.directory, true)

if (args.hasOwnProperty(`inspect`)) {
args.inspect = args.inspect || 9229
}
if (args.hasOwnProperty(`inspect-brk`)) {
args.inspect = args.inspect || 9229
}

cmd(args)
// Return an empty promise to prevent handlerP from exiting early.
// The development server shouldn't ever exit until the user directly
Expand Down
10 changes: 5 additions & 5 deletions packages/gatsby/src/commands/develop.ts
Expand Up @@ -100,11 +100,11 @@ class ControllableScript {
const args = [tmpFileName]
// Passing --inspect isn't necessary for the child process to launch a port but it allows some editors to automatically attach
if (this.debugInfo) {
args.push(
this.debugInfo.break
? `--inspect-brk=${this.debugInfo.port}`
: `--inspect=${this.debugInfo.port}`
)
if (this.debugInfo.break) {
args.push(`--inspect-brk=${this.debugInfo.port}`)
} else {
args.push(`--inspect=${this.debugInfo.port}`)
}
}

this.process = spawn(`node`, args, {
Expand Down

0 comments on commit 93fdc09

Please sign in to comment.