Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return false in production environments #1179

Merged
merged 4 commits into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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