patch: add support for changing directory

This commit is contained in:
Bo Anderson 2020-03-08 18:33:04 +00:00
parent a6158d621b
commit 43d6caf0e3
2 changed files with 10 additions and 1 deletions

View File

@ -135,7 +135,7 @@ class ExternalPatch
end
def apply
dir = Pathname.pwd
base_dir = Pathname.pwd
resource.unpack do
patch_dir = Pathname.pwd
if patch_files.empty?
@ -149,6 +149,8 @@ class ExternalPatch
patch_files << children.first.basename
end
dir = base_dir
dir /= resource.directory if resource.directory.present?
dir.cd do
patch_files.each do |patch_file|
ohai "Applying #{patch_file}"

View File

@ -198,6 +198,7 @@ class Resource
def initialize(&block)
@patch_files = []
@directory = nil
super "patch", &block
end
@ -206,6 +207,12 @@ class Resource
@patch_files.concat(paths)
@patch_files.uniq!
end
def directory(val = nil)
return @directory if val.nil?
@directory = val
end
end
end