Sha256: 8dc160746cdb642cc6ad0d425e7daf92f003bdc7567196099be13a2ec50a047d
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require_relative 'output' module Arli module Helpers module SystemCommands include Output def handle_preexisting_folder(to) if Dir.exist?(to) if abort? raise ::Arli::Errors::LibraryAlreadyExists, "Directory #{to} already exists" elsif backup? backup!(to) elsif overwrite? FileUtils.rm_rf(to) end end end def backup!(p) if Dir.exist?(p) backup_path = "#{p}.arli-backup-#{Time.now.strftime('%Y%m%d%H%M%S')}" FileUtils.mv(p, backup_path) print_target_dir(backup_path, 'backed up') if verbose? ___ "\nNOTE: path #{p.blue} has been backed up to #{backup_path.bold.green}\n" end end end # @param <String> *args — list of arguments or a single string def run_system_command(*args) cmd = args.join(' ') raise 'No command to run was given' unless cmd info("\n" + cmd.green) if Arli.debug? o, e, s = Open3.capture3(cmd) info("\n" + o) if o if Arli.debug? info("\n" + e.red) if e && Arli.debug? rescue Exception => e error "Error running [#{args.join(' ')}]\n" + "Current folder is [#{Dir.pwd.yellow}]", e raise e end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
arli-1.0.1 | lib/arli/helpers/system_commands.rb |
arli-1.0.0 | lib/arli/helpers/system_commands.rb |