Sha256: fb8955deb2339c43a18b6f1a5639bfcafb1c681c93220f07d7b69c1cb627d5fa

Contents?: true

Size: 1.28 KB

Versions: 21

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Jekyll
  module Commands
    class Clean < Command
      class << self
        def init_with_program(prog)
          prog.command(:clean) do |c|
            c.syntax "clean [subcommand]"
            c.description "Clean the site " \
                  "(removes site output and metadata file) without building."

            add_build_options(c)

            c.action do |_, options|
              Jekyll::Commands::Clean.process(options)
            end
          end
        end

        def process(options)
          options = configuration_from_options(options)
          destination = options["destination"]
          metadata_file = File.join(options["source"], ".jekyll-metadata")
          sass_cache = ".sass-cache"

          remove(destination, :checker_func => :directory?)
          remove(metadata_file, :checker_func => :file?)
          remove(sass_cache, :checker_func => :directory?)
        end

        def remove(filename, checker_func: :file?)
          if File.public_send(checker_func, filename)
            Jekyll.logger.info "Cleaner:", "Removing #{filename}..."
            FileUtils.rm_rf(filename)
          else
            Jekyll.logger.info "Cleaner:", "Nothing to do for #{filename}."
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
jekyll-3.10.0 lib/jekyll/commands/clean.rb
jekyll-3.9.5 lib/jekyll/commands/clean.rb
jekyll-3.9.4 lib/jekyll/commands/clean.rb
jekyll-3.9.3 lib/jekyll/commands/clean.rb
jekyll-3.9.2 lib/jekyll/commands/clean.rb
jekyll-3.9.1 lib/jekyll/commands/clean.rb
jekyll-3.9.0 lib/jekyll/commands/clean.rb
jekyll-3.8.7 lib/jekyll/commands/clean.rb
jekyll-3.8.6 lib/jekyll/commands/clean.rb
jekyll-3.8.5 lib/jekyll/commands/clean.rb
jekyll-3.8.4 lib/jekyll/commands/clean.rb
jekyll-3.7.4 lib/jekyll/commands/clean.rb
jekyll-3.8.3 lib/jekyll/commands/clean.rb
jekyll-3.8.2 lib/jekyll/commands/clean.rb
jekyll-3.8.1 lib/jekyll/commands/clean.rb
jekyll-3.8.0 lib/jekyll/commands/clean.rb
jekyll-3.8.0.pre.rc2 lib/jekyll/commands/clean.rb
jekyll-3.8.0.pre.rc1 lib/jekyll/commands/clean.rb
jekyll-3.7.3 lib/jekyll/commands/clean.rb
jekyll-3.7.2 lib/jekyll/commands/clean.rb