lib/middleman-remover/extension.rb in middleman-remover-1.0.0 vs lib/middleman-remover/extension.rb in middleman-remover-1.0.1
- old
+ new
@@ -1,36 +1,35 @@
require 'fileutils'
module Middleman
module Remover
+ # Middleman Remover Extension
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
+ extension = self
app.after_build do
- ext.remove(paths, build_dir)
+ extension.remove(paths, build_dir)
end
end
def remove(paths, dir)
paths.each do |path|
- path = File.join(dir, path)
- list = Dir.glob(path)
+ full_path = File.join(dir, path)
+ files = Dir.glob(full_path)
- if list.length > 0
- FileUtils.rm_rf(list)
- puts " middleman-remover: #{path} is removed"
+ if files.length > 0
+ FileUtils.rm_rf(files)
+ app.logger.info "== middleman-remover: #{path} is removed =="
else
- puts " middleman-remover: #{path} is not exist"
+ app.logger.info "== middleman-remover: #{path} is not exist =="
end
end
end
end
end
end
-