Sha256: 62614229cbc716cd55fbc4d28e3b0546d9bcfa6bb472dfc54a75f1db21da9046

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module Thredded
  module MarkdownKatex
    # Installs Thredded Katex plugin
    class InstallGenerator < Rails::Generators::Base
      desc 'Installs Thredded Katex plugin.'
      public_task :install

      def install # rubocop:disable Metrics/MethodLength
        %w(application.scss _deps.scss).each do |scss_file|
          scss_path = File.join('app', 'assets', 'stylesheets', scss_file)
          next unless File.exist? scss_path
          append_to_file scss_path, "\n" + '@import "_katex";' + "\n"
        end
        sass_path = 'app/assets/stylesheets/application.sass'
        if File.exist? sass_path
          append_to_file sass_path, "\n" + '@import "_katex"' + "\n"
        end
        css_path = 'app/assets/stylesheets/application.css'
        if File.exist? css_path # rubocop:disable Style/GuardClause
          append_to_file css_path, "\n" + '//= require katex' + "\n"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thredded-markdown_katex-0.1.2 lib/generators/thredded/markdown_katex/install_generator.rb