From f705915e17077eea9b5ad95b59804fc6861e44bf Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Tue, 21 Nov 2017 10:27:04 -0700 Subject: [PATCH 1/2] Restore setting windows host to localhost --- packages/gatsby-cli/src/create-cli.js | 2 +- packages/gatsby/src/commands/develop.js | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/gatsby-cli/src/create-cli.js b/packages/gatsby-cli/src/create-cli.js index 1fac81455f53b..dd3dd6b8c11f6 100644 --- a/packages/gatsby-cli/src/create-cli.js +++ b/packages/gatsby-cli/src/create-cli.js @@ -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 } diff --git a/packages/gatsby/src/commands/develop.js b/packages/gatsby/src/commands/develop.js index 8dd1cf49aeb18..0212bc5bbb636 100644 --- a/packages/gatsby/src/commands/develop.js +++ b/packages/gatsby/src/commands/develop.js @@ -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() @@ -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, @@ -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. @@ -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!`)) From 56d0e39eb14891160d1476b7c56b22f0397af075 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Tue, 21 Nov 2017 10:28:00 -0700 Subject: [PATCH 2/2] Format --- packages/gatsby-cli/src/create-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby-cli/src/create-cli.js b/packages/gatsby-cli/src/create-cli.js index dd3dd6b8c11f6..957cc708e6121 100644 --- a/packages/gatsby-cli/src/create-cli.js +++ b/packages/gatsby-cli/src/create-cli.js @@ -14,7 +14,7 @@ const handlerP = fn => (...args) => { } function buildLocalCommands(cli, isLocalSite) { - const defaultHost = process.platform === "win32" ? "localhost" : "0.0.0.0" + const defaultHost = process.platform === `win32` ? `localhost` : `0.0.0.0` const directory = path.resolve(`.`) let siteInfo = { directory, browserslist: DEFAULT_BROWSERS }