Sha256: 7fbe0dca2c9b2de254e916df71bbd19fbe486c8c5219d832f05d477831cdce24

Contents?: true

Size: 1.34 KB

Versions: 43

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module Bridgetown
  module Commands
    class Clean < Thor::Group
      extend BuildOptions
      extend Summarizable
      include ConfigurationOverridable

      Registrations.register do
        register(Clean, "clean", "clean", Clean.summary)
      end

      def self.banner
        "bridgetown clean [options]"
      end
      summary "Clean the site (removes site output and metadata file) without building"

      def clean
        config = configuration_with_overrides(options)
        destination = config["destination"]
        metadata_file = File.join(config["root_dir"], ".bridgetown-metadata")
        cache_dir = File.join(config["root_dir"], config["cache_dir"])
        webpack_dir = File.join(config["root_dir"], ".bridgetown-webpack")

        remove(destination, checker_func: :directory?)
        remove(metadata_file, checker_func: :file?)
        remove(cache_dir, checker_func: :directory?)
        remove(webpack_dir, checker_func: :directory?)
      end

      protected

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

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
bridgetown-core-1.0.0.alpha11 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha10 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha9 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha8 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha7 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha6 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha5 lib/bridgetown-core/commands/clean.rb
bridgetown-core-0.21.5 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha4 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha3 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha2 lib/bridgetown-core/commands/clean.rb
bridgetown-core-1.0.0.alpha1 lib/bridgetown-core/commands/clean.rb
bridgetown-core-0.21.4 lib/bridgetown-core/commands/clean.rb
bridgetown-core-0.21.3 lib/bridgetown-core/commands/clean.rb
bridgetown-core-0.21.2 lib/bridgetown-core/commands/clean.rb
bridgetown-core-0.21.1 lib/bridgetown-core/commands/clean.rb
bridgetown-core-0.21.0 lib/bridgetown-core/commands/clean.rb
bridgetown-core-0.21.0.beta4 lib/bridgetown-core/commands/clean.rb
bridgetown-core-0.21.0.beta3 lib/bridgetown-core/commands/clean.rb
bridgetown-core-0.21.0.beta2 lib/bridgetown-core/commands/clean.rb