Sha256: eea1f80758c1e371c5416f4a832772dcdb94a012fdda93d64b48debc072045cd
Contents?: true
Size: 1021 Bytes
Versions: 31
Compression:
Stored size: 1021 Bytes
Contents
# frozen_string_literal: true require 'fileutils' require 'bolt/error' module Bolt class ProjectManager class Migrator def initialize(outputter) @outputter = outputter end protected def backup_file(origin_path, backup_dir) unless File.exist?(origin_path) @outputter.print_action_step( "Could not find file #{origin_path}, skipping backup." ) return end date = Time.new.strftime("%Y%m%d_%H%M%S%L") FileUtils.mkdir_p(backup_dir) filename = File.basename(origin_path) backup_path = File.join(backup_dir, "#{filename}.#{date}.bak") @outputter.print_action_step( "Backing up #{filename} from #{origin_path} to #{backup_path}" ) begin FileUtils.cp(origin_path, backup_path) rescue StandardError => e raise Bolt::FileError.new("#{e.message}; unable to create backup of #{filename}.", origin_path) end end end end end
Version data entries
31 entries across 31 versions & 1 rubygems