Migrate pretty-text to .js extensions ()

This commit is contained in:
Robin Ward 2020-03-20 09:55:42 -04:00 committed by GitHub
parent 8174f1551c
commit c150566506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 7 additions and 3 deletions

@ -37,7 +37,8 @@ class DiscourseJsProcessor
relative_path = filename.sub(Rails.root.to_s, '').sub(/^\/*/, '')
relative_path.start_with?("app/assets/javascripts/discourse/") ||
relative_path.start_with?("app/assets/javascripts/admin/")
relative_path.start_with?("app/assets/javascripts/admin/") ||
relative_path.start_with?("app/assets/javascripts/pretty-text/")
end
def self.skip_module?(data)

@ -23,6 +23,9 @@ module PrettyText
erb_name = "#{filename}.js.es6.erb"
return erb_name if File.file?("#{root}#{erb_name}")
erb_name = "#{filename}.js.erb"
return erb_name if File.file?("#{root}#{erb_name}")
end
def self.apply_es6_file(ctx, root_path, part_name)
@ -55,7 +58,7 @@ module PrettyText
elsif l =~ /\/\/= require_tree (\.\/)?(.*)$/
path = Regexp.last_match[2]
Dir["#{root_path}/#{path}/**"].sort.each do |f|
apply_es6_file(ctx, root_path, f.sub(root_path, '')[1..-1].sub(/\.js.es6$/, ''))
apply_es6_file(ctx, root_path, f.sub(root_path, '')[1..-1].sub(/\.js(.es6)?$/, ''))
end
end
end
@ -94,7 +97,7 @@ module PrettyText
to_load.uniq.each do |f|
if f =~ /^.+assets\/javascripts\//
root = Regexp.last_match[0]
apply_es6_file(ctx, root, f.sub(root, '').sub(/\.js\.es6$/, ''))
apply_es6_file(ctx, root, f.sub(root, '').sub(/\.js(\.es6)?$/, ''))
end
end