Skip to content

Commit 93fdc09

Browse files
authoredAug 31, 2020
fix(gatsby): only enable debugger when argument is given (#26669)
1 parent 7e83ace commit 93fdc09

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed
 

‎packages/gatsby-cli/src/create-cli.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,23 @@ function buildLocalCommands(cli: yargs.Argv, isLocalSite: boolean): void {
175175
.option(`inspect`, {
176176
type: `number`,
177177
describe: `Opens a port for debugging. See https://www.gatsbyjs.org/docs/debugging-the-build-process/`,
178-
default: 9229,
179178
})
180179
.option(`inspect-brk`, {
181180
type: `number`,
182181
describe: `Opens a port for debugging. Will block until debugger is attached. See https://www.gatsbyjs.org/docs/debugging-the-build-process/`,
183-
default: 9229,
184182
}),
185183
handler: handlerP(
186184
getCommandHandler(`develop`, (args: yargs.Arguments, cmd: Function) => {
187185
process.env.NODE_ENV = process.env.NODE_ENV || `development`
188186
startGraphQLServer(siteInfo.directory, true)
187+
188+
if (args.hasOwnProperty(`inspect`)) {
189+
args.inspect = args.inspect || 9229
190+
}
191+
if (args.hasOwnProperty(`inspect-brk`)) {
192+
args.inspect = args.inspect || 9229
193+
}
194+
189195
cmd(args)
190196
// Return an empty promise to prevent handlerP from exiting early.
191197
// The development server shouldn't ever exit until the user directly

‎packages/gatsby/src/commands/develop.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ class ControllableScript {
100100
const args = [tmpFileName]
101101
// Passing --inspect isn't necessary for the child process to launch a port but it allows some editors to automatically attach
102102
if (this.debugInfo) {
103-
args.push(
104-
this.debugInfo.break
105-
? `--inspect-brk=${this.debugInfo.port}`
106-
: `--inspect=${this.debugInfo.port}`
107-
)
103+
if (this.debugInfo.break) {
104+
args.push(`--inspect-brk=${this.debugInfo.port}`)
105+
} else {
106+
args.push(`--inspect=${this.debugInfo.port}`)
107+
}
108108
}
109109

110110
this.process = spawn(`node`, args, {

0 commit comments

Comments
 (0)
Please sign in to comment.