Skip to content

Conversation

@reznord
Copy link
Member

@reznord reznord commented Jul 5, 2017

This PR opens dev server in a new port if the default port is already in use.

Here's how it looks:
image 2017-07-06 at 2 19 44 am

@reznord
Copy link
Member Author

reznord commented Jul 5, 2017

Oops !! committed package-lock.json file by mistake !!

My bad :(

process.stdout.write(chalk.green('Compiled successfully!!\n\n'));
process.stdout.write('You can view the application in the browser.\n\n');
process.stdout.write(chalk.green('\nCompiled successfully!!\n\n'));
if (parseInt(port, 10) !== parseInt(config.devServer.port, 10)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Showing this message only when it is not using default port. So, it will be easy for the users to understand what port it has been changed to !!

Copy link
Member

@lukeed lukeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should still respect the hierarchy of user-defined ports:

process.env.PORT || config.devServer.port || 8080

@reznord
Copy link
Member Author

reznord commented Jul 5, 2017

This fixes #179

@reznord reznord requested review from developit and rkostrzewski July 5, 2017 21:23
Copy link
Member

@lukeed lukeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot I could push to PRs 😅

I added changes so that we only showed the "using different port" message if user actually defined a port. Since 8080 is a default (aka, not specified) I don't think we have to warn/alert users about the change.

Also, moved parseInt call to process.env.PORT only because it's the only item that is passed in as a string.

Looks good, thanks!!

@lukeed lukeed merged commit a03ef8b into preactjs:master Jul 5, 2017
@lukeed lukeed modified the milestone: 1.4.0 Jul 5, 2017
@reznord reznord deleted the suggest_port branch July 5, 2017 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants