From 1f2c4be7c2d7bf155130e3672fb23f9f807697c9 Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Tue, 9 Jan 2018 17:06:10 -0700 Subject: [PATCH 1/3] Add warning when HOST environment variable is set (#3719) --- packages/react-scripts/scripts/start.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 7eb7ad464c0..dfc469fe876 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -51,6 +51,19 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000; const HOST = process.env.HOST || '0.0.0.0'; +if (process.env.HOST) { + console.log( + chalk.yellow( + "Attempting to bind to $HOST because it was specified. If this was unintentional, check that you haven't mistakenly set it in your shell." + ) + ); + console.log( + chalk.cyan( + 'https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#advanced-configuration\n' + ) + ); +} + // We attempt to use the default port but if it is busy, we offer the user to // run on a different port. `choosePort()` Promise resolves to the next free port. choosePort(HOST, DEFAULT_PORT) From 0092d96a594e768fcd92d8c8dd954581a44c6f2a Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Sun, 14 Jan 2018 11:29:40 -0700 Subject: [PATCH 2/3] Improve HOST environment variable warning message --- packages/react-scripts/scripts/start.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index dfc469fe876..97fee984bbf 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -54,14 +54,11 @@ const HOST = process.env.HOST || '0.0.0.0'; if (process.env.HOST) { console.log( chalk.yellow( - "Attempting to bind to $HOST because it was specified. If this was unintentional, check that you haven't mistakenly set it in your shell." - ) - ); - console.log( - chalk.cyan( - 'https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#advanced-configuration\n' + `Attempting to bind to HOST environment variable: ${process.env + .HOST}. If this was unintentional, check that you haven't mistakenly set it in your shell.` ) ); + console.log(chalk.yellow('Learn more here: http://bit.ly/2mwWSwH\n')); } // We attempt to use the default port but if it is busy, we offer the user to From 8e976d15975143d01817fcdc248dca7a75dc4004 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sun, 14 Jan 2018 14:14:04 -0500 Subject: [PATCH 3/3] Adjust text and message --- packages/react-scripts/scripts/start.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 97fee984bbf..3ff1b91f435 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -53,12 +53,17 @@ const HOST = process.env.HOST || '0.0.0.0'; if (process.env.HOST) { console.log( - chalk.yellow( - `Attempting to bind to HOST environment variable: ${process.env - .HOST}. If this was unintentional, check that you haven't mistakenly set it in your shell.` + chalk.cyan( + `Attempting to bind to HOST environment variable: ${chalk.yellow( + chalk.bold(process.env.HOST) + )}` ) ); - console.log(chalk.yellow('Learn more here: http://bit.ly/2mwWSwH\n')); + console.log( + `If this was unintentional, check that you haven't mistakenly set it in your shell.` + ); + console.log(`Learn more here: ${chalk.yellow('http://bit.ly/2mwWSwH')}`); + console.log(); } // We attempt to use the default port but if it is busy, we offer the user to