diff --git a/README.md b/README.md index 386da6a..8353f77 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,13 @@ Adjust these values accordingly. ## Step 4 middleman build [--clean] - middleman deploy [--clean] + middleman deploy [--clean --build-before] + +To run `middleman build` before `middleman deploy`, add: + + deploy.build_before = true + +Default is `false`. ## NOTES diff --git a/lib/middleman-deploy/commands.rb b/lib/middleman-deploy/commands.rb index b5f4bbe..0cd9afa 100644 --- a/lib/middleman-deploy/commands.rb +++ b/lib/middleman-deploy/commands.rb @@ -27,8 +27,17 @@ module Middleman :type => :boolean, :aliases => "-c", :desc => "Remove orphaned files or directories on the remote host" + method_option "build_before", + :type => :boolean, + :aliases => "-b", + :desc => "Run `middleman build` before the deploy step" def deploy - Middleman::Cli::Build.new.build if self.deploy_options.force_build + if options.has_key? "build_before" + build_before = options.build_before + else + build_before = self.deploy_options.build_before + end + Middleman::Cli::Build.new.build if build_before send("deploy_#{self.deploy_options.method}") end diff --git a/lib/middleman-deploy/extension.rb b/lib/middleman-deploy/extension.rb index ba7699d..3e13e09 100644 --- a/lib/middleman-deploy/extension.rb +++ b/lib/middleman-deploy/extension.rb @@ -5,7 +5,7 @@ require "middleman-core" module Middleman module Deploy - class Options < Struct.new(:whatisthis, :method, :host, :port, :user, :password, :path, :clean, :remote, :branch, :force_build); end + class Options < Struct.new(:whatisthis, :method, :host, :port, :user, :password, :path, :clean, :remote, :branch, :build_before); end class << self @@ -22,7 +22,7 @@ module Middleman options.remote ||= "origin" options.branch ||= "gh-pages" - options.force_build ||= false + options.build_before ||= false @@options = options