Commit be432924 authored by Joe Haddad's avatar Joe Haddad Committed by Dan Abramov
Browse files

Temporarily fork detect-port (#2147)

* Temporarily fork detect-port

* Fix get process id

* Use different package

* Unnecessary var
parent 06e73fa6
3 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file
Showing with 10 additions and 11 deletions
+10 -11
...@@ -27,10 +27,9 @@ function isProcessAReactApp(processCommand) { ...@@ -27,10 +27,9 @@ function isProcessAReactApp(processCommand) {
} }
function getProcessIdOnPort(port) { function getProcessIdOnPort(port) {
return execSync( return execSync('lsof -i:' + port + ' -P -t -sTCP:LISTEN', execOptions)
'lsof -i:' + port + ' -P -t -sTCP:LISTEN', .split('\n')[0]
execOptions .trim();
).trim();
} }
function getPackageNameInDirectory(directory) { function getPackageNameInDirectory(directory) {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"connect-history-api-fallback": "1.3.0", "connect-history-api-fallback": "1.3.0",
"cross-spawn": "4.0.2", "cross-spawn": "4.0.2",
"css-loader": "0.28.0", "css-loader": "0.28.0",
"detect-port": "1.1.1", "@timer/detect-port": "1.1.2",
"dotenv": "2.0.0", "dotenv": "2.0.0",
"eslint": "3.16.1", "eslint": "3.16.1",
"eslint-config-react-app": "^0.6.1", "eslint-config-react-app": "^0.6.1",
......
...@@ -24,7 +24,7 @@ require('../config/env'); ...@@ -24,7 +24,7 @@ require('../config/env');
const fs = require('fs'); const fs = require('fs');
const chalk = require('chalk'); const chalk = require('chalk');
const detect = require('detect-port'); const detect = require('@timer/detect-port');
const WebpackDevServer = require('webpack-dev-server'); const WebpackDevServer = require('webpack-dev-server');
const clearConsole = require('react-dev-utils/clearConsole'); const clearConsole = require('react-dev-utils/clearConsole');
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles'); const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
...@@ -48,10 +48,10 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { ...@@ -48,10 +48,10 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
// Tools like Cloud9 rely on this. // Tools like Cloud9 rely on this.
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000; const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
const HOST = process.env.HOST || '0.0.0.0';
function run(port) { function run(port) {
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'; const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
const host = process.env.HOST || '0.0.0.0';
// Create a webpack compiler that is configured with custom messages. // Create a webpack compiler that is configured with custom messages.
const compiler = createWebpackCompiler( const compiler = createWebpackCompiler(
...@@ -63,7 +63,7 @@ function run(port) { ...@@ -63,7 +63,7 @@ function run(port) {
console.log(); console.log();
console.log('The app is running at:'); console.log('The app is running at:');
console.log(); console.log();
console.log(` ${chalk.cyan(`${protocol}://${host}:${port}/`)}`); console.log(` ${chalk.cyan(`${protocol}://${HOST}:${port}/`)}`);
console.log(); console.log();
console.log('Note that the development build is not optimized.'); console.log('Note that the development build is not optimized.');
console.log( console.log(
...@@ -80,7 +80,7 @@ function run(port) { ...@@ -80,7 +80,7 @@ function run(port) {
addWebpackMiddleware(devServer) addWebpackMiddleware(devServer)
.then(() => { .then(() => {
// Launch WebpackDevServer. // Launch WebpackDevServer.
devServer.listen(port, host, err => { devServer.listen(port, HOST, err => {
if (err) { if (err) {
return console.log(err); return console.log(err);
} }
...@@ -91,7 +91,7 @@ function run(port) { ...@@ -91,7 +91,7 @@ function run(port) {
console.log(chalk.cyan('Starting the development server...')); console.log(chalk.cyan('Starting the development server...'));
console.log(); console.log();
openBrowser(`${protocol}://${host}:${port}/`); openBrowser(`${protocol}://${HOST}:${port}/`);
}); });
}) })
.catch(e => { .catch(e => {
...@@ -105,7 +105,7 @@ function run(port) { ...@@ -105,7 +105,7 @@ function run(port) {
// We attempt to use the default port but if it is busy, we offer the user to // We attempt to use the default port but if it is busy, we offer the user to
// run on a different port. `detect()` Promise resolves to the next free port. // run on a different port. `detect()` Promise resolves to the next free port.
detect(DEFAULT_PORT).then(port => { detect(DEFAULT_PORT, HOST).then(port => {
if (port === DEFAULT_PORT) { if (port === DEFAULT_PORT) {
run(port); run(port);
return; return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment