14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/generators/fluxbit/pagy_generator.rb', line 14
def import_into_application_css
import_line = "@import \"./fluxbit_pagy\";"
tailwind_path = "app/assets/stylesheets/application.tailwind.css"
default_path = "app/assets/stylesheets/application.css"
target_file = if File.exist?(tailwind_path)
tailwind_path
elsif File.exist?(default_path)
default_path
else
say_status :error, "No application CSS file found (expected application.tailwind.css or application.css)", :red
return
end
if File.exist?(target_file)
unless File.read(target_file).include?(import_line)
append_to_file target_file, "\n#{import_line}\n"
else
say_status :skipped, "#{import_line} already present in #{target_file}"
end
else
say_status :error, "#{target_file} not found", :red
end
end
|