Skip to content

Commit

Permalink
Return false in production environments (#1179)
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravtiwari authored Jan 15, 2018
1 parent f74f531 commit 8429874
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
**Please note that Webpacker 3.1.0 and 3.1.1 has some serious bugs so please consider using either 3.0.2 or 3.2.0**

## [Unreleased]

- Disable dev server running? check if no dev server config is present in that environment [#1179](https://github.com/rails/webpacker/pull/1179)

## [3.2.0] - 2017-12-16

### To upgrade:
Expand Down
8 changes: 6 additions & 2 deletions lib/webpacker/dev_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ def initialize(webpacker)
end

def running?
Socket.tcp(host, port, connect_timeout: connect_timeout).close
true
if config.dev_server.present?
Socket.tcp(host, port, connect_timeout: connect_timeout).close
true
else
false
end
rescue
false
end
Expand Down
7 changes: 7 additions & 0 deletions test/dev_server_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
require "test_helper"

class DevServerTest < Webpacker::Test
def test_running?
with_node_env("production") do
reloaded_config
refute Webpacker.dev_server.running?
end
end

def test_host
with_node_env("development") do
reloaded_config
Expand Down

0 comments on commit 8429874

Please sign in to comment.