FIX: Allow plugins to provide test directories with transpiled .js

This commit is contained in:
Robin Ward 2020-06-16 14:30:25 -04:00
parent c52191d49e
commit 7f8c5cf70b
2 changed files with 7 additions and 3 deletions

View File

@ -548,6 +548,9 @@ class Plugin::Instance
if transpile_js
DiscourseJsProcessor.plugin_transpile_paths << root_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')
DiscourseJsProcessor.plugin_transpile_paths << admin_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')
test_path = "#{root_dir_name}/test/javascripts"
DiscourseJsProcessor.plugin_transpile_paths << test_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')
end
end

View File

@ -12,8 +12,9 @@
Discourse.plugins.each do |p|
root_path = "#{File.dirname(p.path)}/test/javascripts"
Dir.glob(root_path + '/**/**.es6').each do |f|
require_asset(f)
end
to_glob = [root_path + '/**/**.es6']
to_glob << (root_path + '/**/**.js') if p.transpile_js
Dir.glob(to_glob) { |f| require_asset(f) }
end
%>