guardfile work
This commit is contained in:
parent
6639f1c6e7
commit
3f8d089701
79
Guardfile
79
Guardfile
@ -16,47 +16,68 @@
|
||||
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
||||
|
||||
guard 'livereload' do
|
||||
watch(%r{app/assets/.+\.(scss|css|js|erb)})
|
||||
watch(%r{app/views/.+\.(erb|haml|slim)$})
|
||||
watch(%r{app/controllers/.+\.rb})
|
||||
watch(%r{app/helpers/.+\.rb})
|
||||
watch(%r{public/.+\.(css|js|html)})
|
||||
extensions = {
|
||||
css: :css,
|
||||
scss: :css,
|
||||
sass: :css,
|
||||
js: :js,
|
||||
coffee: :js,
|
||||
html: :html,
|
||||
png: :png,
|
||||
gif: :gif,
|
||||
jpg: :jpg,
|
||||
jpeg: :jpeg,
|
||||
# less: :less, # uncomment if you want LESS stylesheets done in browser
|
||||
}
|
||||
|
||||
rails_view_exts = %w(erb haml slim)
|
||||
|
||||
# file types LiveReload may optimize refresh for
|
||||
compiled_exts = extensions.values.uniq
|
||||
watch(%r{public/.+\.(#{compiled_exts * '|'})})
|
||||
|
||||
extensions.each do |ext, type|
|
||||
watch(%r{
|
||||
(?:app|vendor)
|
||||
(?:/assets/\w+/(?<path>[^.]+) # path+base without extension
|
||||
(?<ext>\.#{ext})) # matching extension (must be first encountered)
|
||||
(?:\.\w+|$) # other extensions
|
||||
}x) do |m|
|
||||
path = m[1]
|
||||
"/assets/#{path}.#{type}"
|
||||
end
|
||||
end
|
||||
|
||||
# file needing a full reload of the page anyway
|
||||
watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$})
|
||||
watch(%r{app/(helpers|controllers)/.+\.rb})
|
||||
watch(%r{config/locales/.+\.yml})
|
||||
|
||||
# Rails Assets Pipeline
|
||||
watch(%r{(app|vendor)(/assets/\w+/(.+\.(scss|css|js|erb|html|png|jpg))).*}) do |m|
|
||||
"/assets/#{m[3]}"
|
||||
end
|
||||
end
|
||||
|
||||
guard :minitest, spring: true, all_after_pass: true do
|
||||
guard :minitest, spring: "bin/rails test" do # all_after_pass: true
|
||||
watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
||||
watch(%r{^app/controllers/(admin|application)_controller\.rb$}) { 'test/controllers' }
|
||||
watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
|
||||
watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
||||
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
||||
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
|
||||
|
||||
# run tests when touching files matching: /app/**/*.rb
|
||||
watch(%r{^app/(.*/)?([^/]+)\.rb$}) { |m| ["test/#{m[1]}#{m[2]}_test.rb", "test/#{m[1]}#{m[2]}"] }
|
||||
|
||||
# run tests when touching files matching: /lib/**/*.rb
|
||||
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| ["test/lib/#{m[1]}#{m[2]}_test.rb", "test/lib/#{m[1]}#{m[2]}"] }
|
||||
|
||||
watch(%r{^test/.+_test\.rb$})
|
||||
# run controller/integration test when touching erb files
|
||||
watch(%r{^app/views/((?!_mailer).)*([^/]+)\.erb$}) { ["test/controllers", "test/integration"] }
|
||||
|
||||
# run mailers/integration test when touching mailer erb files
|
||||
watch(%r{^app/views/(.*_mailer/)?([^/]+)\.erb$}) { ["test/mailers", "test/integration"] }
|
||||
end
|
||||
|
||||
# ESLint
|
||||
guard :shell, all_on_start: true do
|
||||
watch %r{app/assets/javascripts/*/.*} do |file|
|
||||
system %(echo "ESLinting \033[32m#{file[0]}\033[0m")
|
||||
system %(eslint #{file[0]})
|
||||
end
|
||||
end
|
||||
|
||||
guard :rubocop do
|
||||
watch(/.+\.rb$/)
|
||||
watch(/Rakefile/)
|
||||
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
||||
end
|
||||
|
||||
# This breaks in the container.
|
||||
# instead, try using: https://github.com/appfolio/eslint-rails
|
||||
# # ESLint
|
||||
# guard :shell, all_on_start: true do
|
||||
# watch %r{app/assets/javascripts/*/.*} do |file|
|
||||
# `eslint #{file[0]}`
|
||||
# end
|
||||
# end
|
||||
|
@ -9,18 +9,18 @@ if [ -d '/usr/app' ]; then
|
||||
echo "edit and update proper values"
|
||||
echo ''
|
||||
else
|
||||
if [ ! -f '~/.container-setup' ]; then
|
||||
if [ ! -f '/root/.container-setup' ]; then
|
||||
bundle
|
||||
npm install
|
||||
bower install --allow-root
|
||||
rails db:setup
|
||||
rails db:migrate
|
||||
rails db:fixtures:load
|
||||
touch ~/.container-setup
|
||||
touch /root/.container-setup
|
||||
fi
|
||||
tmux new-session -d -s 'rails-dev' 'rails s -b 0.0.0.0'
|
||||
tmux split-window -p 15 -v
|
||||
tmux split-window -p 85 -v 'bundle exec guard'
|
||||
tmux split-window -p 85 -v 'bundle exec guard start --wait-for-delay 1.5'
|
||||
tmux attach -t rails-dev
|
||||
fi
|
||||
else
|
||||
|
@ -9,14 +9,14 @@ if [ -d '/usr/app' ]; then
|
||||
echo "edit and update proper values"
|
||||
echo ''
|
||||
else
|
||||
if [ ! -f '~/.container-setup' ]; then
|
||||
if [ ! -f '/root/.container-setup' ]; then
|
||||
bundle
|
||||
npm install
|
||||
bower install --allow-root
|
||||
rails db:setup
|
||||
rails db:migrate
|
||||
rails db:fixtures:load
|
||||
touch ~/.container-setup
|
||||
touch /root/.container-setup
|
||||
fi
|
||||
echo 'Delete ~/.container-setup and re-run startup script to update app.'
|
||||
rails s -b 0.0.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user