Skip to content

Commit

Permalink
Restore setting windows host to localhost (#2983)
Browse files Browse the repository at this point in the history
* Restore setting windows host to localhost

* Format
  • Loading branch information
KyleAMathews authored Nov 21, 2017
1 parent 97d58a6 commit c280472
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-cli/src/create-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const handlerP = fn => (...args) => {
}

function buildLocalCommands(cli, isLocalSite) {
const defaultHost = `0.0.0.0`
const defaultHost = process.platform === `win32` ? `localhost` : `0.0.0.0`
const directory = path.resolve(`.`)

let siteInfo = { directory, browserslist: DEFAULT_BROWSERS }
Expand Down
16 changes: 4 additions & 12 deletions packages/gatsby/src/commands/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,8 @@ module.exports = async (program: any) => {
})

const isUnspecifiedHost = host === `0.0.0.0` || host === `::`
let prettyHost, lanUrlForConfig, lanUrlForTerminal
let lanUrlForConfig, lanUrlForTerminal
if (isUnspecifiedHost) {
prettyHost = `localhost`
try {
// This can only return an IPv4 address
lanUrlForConfig = address.ip()
Expand All @@ -278,14 +277,12 @@ module.exports = async (program: any) => {
} catch (_e) {
// ignored
}
} else {
prettyHost = host
}
// TODO collect errors (GraphQL + Webpack) in Redux so we
// can clear terminal and print them out on every compile.
// Borrow pretty printing code from webpack plugin.
const localUrlForTerminal = prettyPrintUrl(prettyHost)
const localUrlForBrowser = formatUrl(prettyHost)
const localUrlForTerminal = prettyPrintUrl(host)
const localUrlForBrowser = formatUrl(host)
return {
lanUrlForConfig,
lanUrlForTerminal,
Expand Down Expand Up @@ -318,11 +315,6 @@ module.exports = async (program: any) => {
console.log()
}

const host =
listener.address().address === `127.0.0.1`
? `localhost`
: listener.address().address

let isFirstCompile = true
// "done" event fires when Webpack has finished recompiling the bundle.
// Whether or not you have warnings or errors, you will get this event.
Expand All @@ -331,7 +323,7 @@ module.exports = async (program: any) => {
// options so we are going to "massage" the warnings and errors and present
// them in a readable focused way.
const messages = formatWebpackMessages(stats.toJson({}, true))
const urls = prepareUrls(`http`, host, port)
const urls = prepareUrls(`http`, program.host, program.port)
const isSuccessful = !messages.errors.length && !messages.warnings.length
// if (isSuccessful) {
// console.log(chalk.green(`Compiled successfully!`))
Expand Down

0 comments on commit c280472

Please sign in to comment.