mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #1758 from coopdevs/simplify-karma-rake-task
Always execute local karma
This commit is contained in:
@@ -1,28 +1,22 @@
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
|
||||
namespace :karma do
|
||||
task :start => :environment do |task|
|
||||
continue_only_in_test_env task
|
||||
task :start => :environment do |_task|
|
||||
with_tmp_config :start
|
||||
end
|
||||
|
||||
task :run => :environment do |task|
|
||||
continue_only_in_test_env task
|
||||
task :run => :environment do |_task|
|
||||
with_tmp_config :start, "--single-run"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def continue_only_in_test_env task
|
||||
if Rails.env != 'test'
|
||||
raise "Task must be called in test environment:\n bundle exec rake #{task.name} RAILS_ENV=test"
|
||||
end
|
||||
end
|
||||
|
||||
def with_tmp_config(command, args = nil)
|
||||
Tempfile.open('karma_unit.js', Rails.root.join('tmp') ) do |f|
|
||||
f.write unit_js(application_spec_files << i18n_file)
|
||||
f.flush
|
||||
trap('SIGINT') { puts "Killing Karma"; exit }
|
||||
exec "karma #{command} #{f.path} #{args}"
|
||||
exec "node_modules/.bin/karma #{command} #{f.path} #{args}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user