class Jekyll::Commands::Clean

Public Class Methods

init_with_program(prog) click to toggle source
# File lib/jekyll/commands/clean.rb, line 5
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
process(options) click to toggle source
# File lib/jekyll/commands/clean.rb, line 19
def process(options)
  options = configuration_from_options(options)
  destination = options["destination"]
  metadata_file = File.join(options["source"], ".jekyll-metadata")
  sass_cache = File.join(options["source"], ".sass-cache")

  remove(destination, :checker_func => :directory?)
  remove(metadata_file, :checker_func => :file?)
  remove(sass_cache, :checker_func => :directory?)
end
remove(filename, checker_func: :file?) click to toggle source
# File lib/jekyll/commands/clean.rb, line 30
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