Skip to content

Commit

Permalink
Fix rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rossta committed Sep 16, 2017
1 parent 426a859 commit a49f517
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/doc/
/pkg/
/spec/reports/
/tmp/
/log/
**/tmp/
**/log/
**/node_modules/
/gemfiles/*.lock
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
AllCops:
Exclude:
- "test/tmp/**/*"
- "test/log/**/*"
- "tmp/**/*"
- "coverage/**/*"
- "gemfiles/**/*"
- "**/node_modules/**/*"

Metrics/LineLength:
Max: 120
Expand Down
9 changes: 5 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ task default: %i[test rubocop]

task :compile do
if defined?(Webpacker)
Dir.chdir('test/sample') do
sh 'RAILS_ENV=test ./bin/rake webpacker:compile'
Dir.chdir("test/sample") do
sh "NODE_ENV=test yarn install"
sh "RAILS_ENV=test ./bin/rake webpacker:compile"
end
end
end

Rake::Task[:test].enhance [:compile] do
if defined?(Webpacker)
Dir.chdir('test/sample') do
sh 'RAILS_ENV=test ./bin/rake webpacker:clobber'
Dir.chdir("test/sample") do
sh "RAILS_ENV=test ./bin/rake webpacker:clobber"
end
end
end
8 changes: 4 additions & 4 deletions lib/serviceworker/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def initialize(path_pattern, asset_pattern = nil, options = {})

@path_pattern = path_pattern
@asset_pattern = if options[:pack] && defined?(Webpacker)
asset_pattern || options.fetch(:pack, path_pattern)
else
asset_pattern || options.fetch(:asset, path_pattern)
end
asset_pattern || options.fetch(:pack, path_pattern)
else
asset_pattern || options.fetch(:asset, path_pattern)
end
@options = options
end

Expand Down
2 changes: 1 addition & 1 deletion test/sample/bin/webpack
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ unless File.exist?(WEBPACK_CONFIG)
end

env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
cmd = [ "#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG ] + ARGV
cmd = ["#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG] + ARGV

Dir.chdir(APP_PATH) do
exec env, *cmd
Expand Down
14 changes: 6 additions & 8 deletions test/sample/bin/webpack-dev-server
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml")
NODE_MODULES_PATH = File.join(APP_PATH, "node_modules")
WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/#{NODE_ENV}.js")

DEFAULT_LISTEN_HOST_ADDR = NODE_ENV == 'development' ? 'localhost' : '0.0.0.0'
DEFAULT_LISTEN_HOST_ADDR = NODE_ENV == "development" ? "localhost" : "0.0.0.0"

def args(key)
index = ARGV.index(key)
Expand All @@ -26,12 +26,11 @@ end
begin
dev_server = YAML.load_file(CONFIG_FILE)[RAILS_ENV]["dev_server"]

HOSTNAME = args('--host') || dev_server["host"]
PORT = args('--port') || dev_server["port"]
HTTPS = ARGV.include?('--https') || dev_server["https"]
DEV_SERVER_ADDR = "http#{"s" if HTTPS}://#{HOSTNAME}:#{PORT}"
LISTEN_HOST_ADDR = args('--listen-host') || DEFAULT_LISTEN_HOST_ADDR

HOSTNAME = args("--host") || dev_server["host"]
PORT = args("--port") || dev_server["port"]
HTTPS = ARGV.include?("--https") || dev_server["https"]
DEV_SERVER_ADDR = "http#{"s" if HTTPS}://#{HOSTNAME}:#{PORT}".freeze
LISTEN_HOST_ADDR = args("--listen-host") || DEFAULT_LISTEN_HOST_ADDR
rescue Errno::ENOENT, NoMethodError
$stdout.puts "Webpack dev_server configuration not found in #{CONFIG_FILE}."
$stdout.puts "Please run bundle exec rails webpacker:install to install webpacker"
Expand All @@ -41,7 +40,6 @@ end
begin
server = TCPServer.new(LISTEN_HOST_ADDR, PORT)
server.close

rescue Errno::EADDRINUSE
$stdout.puts "Another program is running on port #{PORT}. Set a new port in #{CONFIG_FILE} for dev_server"
exit!
Expand Down

0 comments on commit a49f517

Please sign in to comment.