lib/specinfra/command/base/file.rb in specinfra-2.53.1 vs lib/specinfra/command/base/file.rb in specinfra-2.54.0

- old
+ new

@@ -135,28 +135,33 @@ def get_size(file) "stat -c %s #{escape(file)}" end - def change_mode(file, mode) - "chmod #{mode} #{escape(file)}" + def change_mode(file, mode, options = {}) + option = '-R' if options[:recursive] + "chmod #{option} #{mode} #{escape(file)}".squeeze(' ') end - def change_owner(file, owner, group=nil) + def change_owner(file, owner, group=nil, options = {}) + option = '-R' if options[:recursive] owner = "#{owner}:#{group}" if group - "chown #{owner} #{escape(file)}" + "chown #{option} #{owner} #{escape(file)}".squeeze(' ') end - def change_group(file, group) - "chgrp #{group} #{escape(file)}" + def change_group(file, group, options = {}) + option = '-R' if options[:recursive] + "chgrp #{option} #{group} #{escape(file)}".squeeze(' ') end def create_as_directory(file) "mkdir -p #{escape(file)}" end - def copy(src, dest) - "cp #{escape(src)} #{escape(dest)}" + def copy(src, dest, options = {}) + option = '-p' + option << 'R' if options[:recursive] + "cp #{option} #{escape(src)} #{escape(dest)}" end def move(src, dest) "mv #{escape(src)} #{escape(dest)}" end