Sha256: aea1622d03bad7475a5dc047fb8ddb183de37e74f39434a86e0d9486c14bb2f5

Contents?: true

Size: 820 Bytes

Versions: 1

Compression:

Stored size: 820 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
        %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'
        append_to_file sass_path, "\n@import \"_katex\"\n" if File.exist? sass_path
        css_path = 'app/assets/stylesheets/application.css'
        append_to_file css_path, "\n//= require katex\n" if File.exist? css_path
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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