From 5dc7b5068de03f91ac94ebe8542bbd4658dbd7c6 Mon Sep 17 00:00:00 2001 From: Nicolas McCurdy Date: Thu, 16 Jan 2014 05:43:20 -0500 Subject: [PATCH 1/2] Replace any system calls in lib that don't use git with calls to FileUtils --- lib/homesick/actions.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index ef6600d..edd2ec0 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -96,16 +96,16 @@ class Homesick if destination.exist? say_status :conflict, "#{destination} exists", :red unless options[:quiet] - system "mv '#{source}' '#{destination}'" if (options[:force] || shell.file_collision(destination) { source }) && !options[:pretend] + FileUtils.mv source, destination if (options[:force] || shell.file_collision(destination) { source }) && !options[:pretend] else # this needs some sort of message here. - system "mv '#{source}' '#{destination}'" unless options[:pretend] + FileUtils.mv source, destination unless options[:pretend] end end def rm_rf(dir) say_status "rm -rf #{dir}", '', :green unless options[:quiet] - system "rm -rf #{dir}" + FileUtils.rm_r dir, force: true end def rm_link(target) @@ -121,12 +121,12 @@ class Homesick def rm(file) say_status "rm #{file}", '', :green unless options[:quiet] - system "rm #{file}" if File.exists?(file) + FileUtils.rm file, force: true end def rm_r(dir) say_status "rm -r #{dir}", '', :green unless options[:quiet] - system "rm -r #{dir}" + FileUtils.rm_r dir end def ln_s(source, destination, config = {}) @@ -156,19 +156,20 @@ class Homesick "#{destination} exists and points to #{destination.readlink}", :red unless options[:quiet] - system "ln -nsf '#{source}' '#{destination}'" if collision_accepted? + FileUtils.rm destination + FileUtils.ln_s source, destination, force: true unless options[:pretend] when :conflict say_status :conflict, "#{destination} exists", :red unless options[:quiet] if collision_accepted? - system "rm -rf '#{destination}'" unless options[:pretend] - system "ln -sf '#{source}' '#{destination}'" unless options[:pretend] + FileUtils.rm_r destination, force: true unless options[:pretend] + FileUtils.ln_s source, destination, force: true unless options[:pretend] end else say_status :symlink, "#{source.expand_path} to #{destination.expand_path}", :green unless options[:quiet] - system "ln -s '#{source}' '#{destination}'" unless options[:pretend] + FileUtils.ln_s source, destination unless options[:pretend] end end end From 84fb1d146277236ab919e3612fa89acbd6ca263a Mon Sep 17 00:00:00 2001 From: Nicolas McCurdy Date: Thu, 16 Jan 2014 06:15:37 -0500 Subject: [PATCH 2/2] Replace a system call in the spec helper --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 52dbf41..6bfca55 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -33,7 +33,7 @@ RSpec.configure do |config| if subdirs subdir_file = castle.join(Homesick::SUBDIR_FILENAME) subdirs.each do |subdir| - system "echo #{subdir} >> #{subdir_file}" + File.open(subdir_file, 'a') { |file| file.write "\n#{subdir}\n" } end end return castle.directory('home')