Merge pull request #1169 from datapimp/before-build-hook
Adding before build hook
This commit is contained in:
commit
049866ee2e
|
@ -40,6 +40,9 @@ module Middleman
|
|||
# Ready (all loading and parsing of extensions complete) hook
|
||||
define_hook :ready
|
||||
|
||||
# Runs before the build is started
|
||||
define_hook :before_build
|
||||
|
||||
# Runs after the build is finished
|
||||
define_hook :after_build
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ module Middleman::Cli
|
|||
opts[:glob] = options['glob'] if options.has_key?('glob')
|
||||
opts[:clean] = options['clean']
|
||||
|
||||
self.class.shared_instance.run_hook :before_build, self
|
||||
|
||||
action BuildAction.new(self, opts)
|
||||
|
||||
self.class.shared_instance.run_hook :after_build, self
|
||||
|
|
|
@ -175,6 +175,7 @@ module Middleman
|
|||
# Bind app hooks to local methods
|
||||
bind_before_configuration
|
||||
bind_after_configuration
|
||||
bind_before_build
|
||||
bind_after_build
|
||||
end
|
||||
|
||||
|
@ -233,6 +234,19 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
def bind_before_build
|
||||
ext = self
|
||||
if ext.respond_to?(:before_build)
|
||||
@klass.before_build do |builder|
|
||||
if ext.method(:before_build).arity === 1
|
||||
ext.before_build(builder)
|
||||
else
|
||||
ext.before_build
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def bind_after_build
|
||||
ext = self
|
||||
if ext.respond_to?(:after_build)
|
||||
|
|
Loading…
Reference in a new issue