Skip to content

Commit

Permalink
Correct HMR port when switching ports fixes #457
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Sep 22, 2016
1 parent bc6d896 commit 34a1549
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/utils/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import globPages from './glob-pages'
import webpackConfig from './webpack.config'
const debug = require('debug')('gatsby:application')

function startServer (program, launchPort) {
function startServer (program) {
const directory = program.directory
const serverPort = launchPort || program.port

// Load pages for the site.
return globPages(directory, (err, pages) => {
Expand Down Expand Up @@ -58,7 +57,7 @@ function startServer (program, launchPort) {

server.connection({
host: program.host,
port: serverPort,
port: program.port,
})

server.route({
Expand Down Expand Up @@ -170,7 +169,7 @@ function startServer (program, launchPort) {
if (e) {
if (e.code === 'EADDRINUSE') {
// eslint-disable-next-line max-len
console.log(`Unable to start Gatsby on port ${serverPort} as there's already a process listing on that port.`)
console.log(`Unable to start Gatsby on port ${program.port} as there's already a process listing on that port.`)
} else {
console.log(e)
}
Expand Down Expand Up @@ -200,12 +199,11 @@ module.exports = (program) => {
const question = `Something is already running at port ${program.port} \nWould you like to run the app at another port instead? [Y/n] `

return rlInterface.question(question, (answer) => {
let launchPort = program.port
if (answer.length === 0 || answer.match(/^yes|y$/i)) {
launchPort = _port
program.port = _port
}

return startServer(program, launchPort)
return startServer(program)
})
}

Expand Down

0 comments on commit 34a1549

Please sign in to comment.