rename "delete" to "clean" (like middleman's build) and override on command-line (if provided)
This commit is contained in:
parent
c4290d9d29
commit
f65564404c
2 changed files with 27 additions and 6 deletions
|
@ -18,15 +18,36 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "deploy", "Deploy to a remote host over rsync"
|
desc "deploy", "Deploy to a remote host over rsync"
|
||||||
|
method_option "clean",
|
||||||
|
:type => :boolean,
|
||||||
|
:aliases => "-c",
|
||||||
|
:desc => "Remove orphaned files or directories on the remote host"
|
||||||
def deploy
|
def deploy
|
||||||
options = ::Middleman::Application.server.inst.options
|
shared_inst = ::Middleman::Application.server.inst
|
||||||
|
|
||||||
|
host = shared_inst.options.host
|
||||||
|
port = shared_inst.options.port
|
||||||
|
user = shared_inst.options.user
|
||||||
|
path = shared_inst.options.path
|
||||||
|
|
||||||
# These only exists when the config.rb sets them!
|
# These only exists when the config.rb sets them!
|
||||||
if (options.host && options.user && options.path)
|
if (!host || !user || !path)
|
||||||
run "rsync -avze '" + "ssh -p #{options.port}" + "' #{"--delete" if options.delete == true} build/ #{options.user}@#{options.host}:#{options.path}"
|
|
||||||
else
|
|
||||||
raise Thor::Error.new "You need to activate the deploy extension in config.rb "
|
raise Thor::Error.new "You need to activate the deploy extension in config.rb "
|
||||||
end
|
end
|
||||||
|
|
||||||
|
command = "rsync -avze '" + "ssh -p #{port}" + "' build/ #{user}@#{host}:#{path}"
|
||||||
|
|
||||||
|
if options.has_key? "clean"
|
||||||
|
clean = options.clean
|
||||||
|
else
|
||||||
|
clean = shared_inst.options.clean
|
||||||
|
end
|
||||||
|
|
||||||
|
if clean
|
||||||
|
command += "--delete"
|
||||||
|
end
|
||||||
|
|
||||||
|
run command
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ require "middleman-core"
|
||||||
# Extension namespace
|
# Extension namespace
|
||||||
module Middleman
|
module Middleman
|
||||||
module Deploy
|
module Deploy
|
||||||
class Options < Struct.new(:delete, :host, :port, :user, :path); end
|
class Options < Struct.new(:host, :port, :user, :path, :clean); end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def options
|
def options
|
||||||
|
@ -14,8 +14,8 @@ module Middleman
|
||||||
options = Options.new(options_hash)
|
options = Options.new(options_hash)
|
||||||
yield options if block_given?
|
yield options if block_given?
|
||||||
|
|
||||||
options.delete ||= false
|
|
||||||
options.port ||= 22
|
options.port ||= 22
|
||||||
|
options.clean ||= false
|
||||||
|
|
||||||
@@options = options
|
@@options = options
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue