Skip to content

Commit 8af1c13

Browse files
Timergaearon
authored andcommitted
Temporarily fork detect-port (facebook#2147)
* Temporarily fork detect-port * Fix get process id * Use different package * Unnecessary var
1 parent 81196d1 commit 8af1c13

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"connect-history-api-fallback": "1.3.0",
3434
"cross-spawn": "4.0.2",
3535
"css-loader": "0.28.0",
36-
"detect-port": "1.1.1",
36+
"@timer/detect-port": "1.1.2",
3737
"dotenv": "2.0.0",
3838
"eslint": "3.16.1",
3939
"eslint-config-react-app": "^0.6.1",

scripts/start.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require('../config/env');
2424

2525
const fs = require('fs');
2626
const chalk = require('chalk');
27-
const detect = require('detect-port');
27+
const detect = require('@timer/detect-port');
2828
const WebpackDevServer = require('webpack-dev-server');
2929
const clearConsole = require('react-dev-utils/clearConsole');
3030
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
@@ -48,10 +48,10 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
4848

4949
// Tools like Cloud9 rely on this.
5050
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
51+
const HOST = process.env.HOST || '0.0.0.0';
5152

5253
function run(port) {
5354
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
54-
const host = process.env.HOST || '0.0.0.0';
5555

5656
// Create a webpack compiler that is configured with custom messages.
5757
const compiler = createWebpackCompiler(
@@ -63,7 +63,7 @@ function run(port) {
6363
console.log();
6464
console.log('The app is running at:');
6565
console.log();
66-
console.log(` ${chalk.cyan(`${protocol}://${host}:${port}/`)}`);
66+
console.log(` ${chalk.cyan(`${protocol}://${HOST}:${port}/`)}`);
6767
console.log();
6868
console.log('Note that the development build is not optimized.');
6969
console.log(
@@ -80,7 +80,7 @@ function run(port) {
8080
addWebpackMiddleware(devServer)
8181
.then(() => {
8282
// Launch WebpackDevServer.
83-
devServer.listen(port, host, err => {
83+
devServer.listen(port, HOST, err => {
8484
if (err) {
8585
return console.log(err);
8686
}
@@ -91,7 +91,7 @@ function run(port) {
9191
console.log(chalk.cyan('Starting the development server...'));
9292
console.log();
9393

94-
openBrowser(`${protocol}://${host}:${port}/`);
94+
openBrowser(`${protocol}://${HOST}:${port}/`);
9595
});
9696
})
9797
.catch(e => {
@@ -105,7 +105,7 @@ function run(port) {
105105

106106
// We attempt to use the default port but if it is busy, we offer the user to
107107
// run on a different port. `detect()` Promise resolves to the next free port.
108-
detect(DEFAULT_PORT).then(port => {
108+
detect(DEFAULT_PORT, HOST).then(port => {
109109
if (port === DEFAULT_PORT) {
110110
run(port);
111111
return;

0 commit comments

Comments
 (0)