Extract command #combine

This commit is contained in:
David Heinemeier Hansson
2023-01-13 10:00:11 +01:00
parent 6ea06fd04e
commit ea9a50ec95
2 changed files with 9 additions and 1 deletions

View File

@@ -9,6 +9,12 @@ module Mrsk::Commands
end
private
def combine(*commands)
commands
.collect { |command| command + [ "&&" ] }.flatten # Join commands with &&
.tap { |commands| commands.pop } # Remove trailing &&
end
def docker(*args)
args.compact.unshift :docker
end

View File

@@ -10,7 +10,9 @@ class Mrsk::Commands::Builder::Native < Mrsk::Commands::Base
end
def push
docker :build, "--push", "-t", config.absolute_image, "."
combine \
docker(:build, "-t", config.absolute_image, "."),
docker(:push, config.absolute_image)
end
def pull