Sha256: 350eda7665052721971412f0578bc698fdafaab139d5921de586b255b8ea217c

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

module Bunto
  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|
              Bunto::Commands::Clean.process(options)
            end
          end
        end

        def process(options)
          options = configuration_from_options(options)
          destination = options["destination"]
          metadata_file = File.join(options["source"], ".bunto-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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bunto-3.4.5 lib/bunto/commands/clean.rb
bunto-3.2.1 lib/bunto/commands/clean.rb