Sha256: 4276aa2ba26c86d2be59dac87f1b960c254081ab1ab41fdf1db3ea8818afd2d5

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

require 'fileutils'

module Middleman
  module Remover
    class Extension < ::Middleman::Extension
      option :paths, [], 'List of remove files/directories paths'

      def initialize(app, options_hash = {}, &block)
        super

        paths     = options.paths
        build_dir = app.build_dir
        ext       = self

        app.after_build do
          ext.remove(paths, build_dir)
        end
      end

      def remove(paths, dir)
        paths.each do |path|
          path = File.join(dir, path)
          list = Dir.glob(path)

          if list.length > 0
            FileUtils.rm_rf(list)
            puts "   middleman-remover: #{path} is removed"
          else
            puts "   middleman-remover: #{path} is not exist"
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-remover-1.0.0 lib/middleman-remover/extension.rb