Skip to content

Commit b2a2d6b

Browse files
fix(gatsby-cli): Open Lan URL if Windows (#16769)
Co-authored-by: Ward Peeters <[email protected]>
1 parent f3b540b commit b2a2d6b

File tree

1 file changed

+7
-38
lines changed

1 file changed

+7
-38
lines changed

packages/gatsby/src/commands/develop.js

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,12 @@ module.exports = async (program: any) => {
398398
})
399399

400400
const isUnspecifiedHost = host === `0.0.0.0` || host === `::`
401-
let lanUrlForConfig, lanUrlForTerminal
401+
let prettyHost = host,
402+
lanUrlForConfig,
403+
lanUrlForTerminal
402404
if (isUnspecifiedHost) {
405+
prettyHost = `localhost`
406+
403407
try {
404408
// This can only return an IPv4 address
405409
lanUrlForConfig = address.ip()
@@ -425,8 +429,8 @@ module.exports = async (program: any) => {
425429
// TODO collect errors (GraphQL + Webpack) in Redux so we
426430
// can clear terminal and print them out on every compile.
427431
// Borrow pretty printing code from webpack plugin.
428-
const localUrlForTerminal = prettyPrintUrl(host)
429-
const localUrlForBrowser = formatUrl(host)
432+
const localUrlForTerminal = prettyPrintUrl(prettyHost)
433+
const localUrlForBrowser = formatUrl(prettyHost)
430434
return {
431435
lanUrlForConfig,
432436
lanUrlForTerminal,
@@ -532,7 +536,6 @@ module.exports = async (program: any) => {
532536
}
533537
})
534538
}
535-
536539
let isFirstCompile = true
537540
// "done" event fires when Webpack has finished recompiling the bundle.
538541
// Whether or not you have warnings or errors, you will get this event.
@@ -547,10 +550,6 @@ module.exports = async (program: any) => {
547550
program.port
548551
)
549552
const isSuccessful = !messages.errors.length
550-
// if (isSuccessful) {
551-
// console.log(chalk.green(`Compiled successfully!`))
552-
// }
553-
// if (isSuccessful && (isInteractive || isFirstCompile)) {
554553
if (isSuccessful && isFirstCompile) {
555554
printInstructions(program.sitePackageJson.name, urls, program.useYarn)
556555
printDeprecationWarnings()
@@ -567,36 +566,6 @@ module.exports = async (program: any) => {
567566

568567
isFirstCompile = false
569568

570-
// If errors exist, only show errors.
571-
// if (messages.errors.length) {
572-
// // Only keep the first error. Others are often indicative
573-
// // of the same problem, but confuse the reader with noise.
574-
// if (messages.errors.length > 1) {
575-
// messages.errors.length = 1
576-
// }
577-
// console.log(chalk.red("Failed to compile.\n"))
578-
// console.log(messages.errors.join("\n\n"))
579-
// return
580-
// }
581-
582-
// Show warnings if no errors were found.
583-
// if (messages.warnings.length) {
584-
// console.log(chalk.yellow("Compiled with warnings.\n"))
585-
// console.log(messages.warnings.join("\n\n"))
586-
587-
// // Teach some ESLint tricks.
588-
// console.log(
589-
// "\nSearch for the " +
590-
// chalk.underline(chalk.yellow("keywords")) +
591-
// " to learn more about each warning."
592-
// )
593-
// console.log(
594-
// "To ignore, add " +
595-
// chalk.cyan("// eslint-disable-next-line") +
596-
// " to the line before.\n"
597-
// )
598-
// }
599-
600569
done()
601570
})
602571
}

0 commit comments

Comments
 (0)