6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/generators/react_rails_modal/install_generator.rb', line 6
def inject_react_rails_modal
require_react_rails_modal = "//= require react_rails_modal\n"
if manifest.exist?
manifest_contents = File.read(manifest)
puts manifest_contents.match(/\/\/=\s+require\s+turbolinks\s+\n/)
puts manifest_contents.match(/\/\/=\s+require_tree[^\n]*/)
if match = manifest_contents.match(/\/\/=\s+require_tree[^\n]*/)
inject_into_file manifest, require_react_rails_modal, { before: match[0] }
else
append_file manifest, require_react_rails_modal
inject_react_rails
end
else
create_file manifest, require_react_rails_modal
inject_react_rails
end
end
|