From 99df3e011bfdadde4cc22bd433ba335d5947060c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Mon, 18 Nov 2013 11:44:07 +0100 Subject: [PATCH] [rake] Raise error if cleaning does not succeed. Fixes https://hipbyte.freshdesk.com/helpdesk/tickets/1359. --- NEWS | 1 + lib/motion/project.rb | 13 +++++++++---- lib/motion/project/vendor.rb | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 45d21236..5f3c0a75 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ released. * Fixed a bug in dispatcher where #super cannot look up the shortcut method. (ie #foo=) + * Raise error if cleaning a build artefact fails. * [iOS] Fixed a bug where `rake device' would no longer print the application logs from the device. * [OSX] Fixed a bug on OSX platform where compiler flags for iOS are passed diff --git a/lib/motion/project.rb b/lib/motion/project.rb index 29c4a509..bb7e6f19 100644 --- a/lib/motion/project.rb +++ b/lib/motion/project.rb @@ -40,14 +40,19 @@ system("/usr/bin/ruby \"#{motion_bin_path}\" update --check") desc "Clear local build objects" task :clean do - App.info 'Delete', App.config.build_dir - rm_rf(App.config.build_dir) - App.config.vendor_projects.each { |vendor| vendor.clean } - Dir.glob(App.config.resources_dirs.flatten.map{ |x| x + '/**/*.{nib,storyboardc,momd}' }).each do |p| + paths = [App.config.build_dir] + paths.concat(Dir.glob(App.config.resources_dirs.flatten.map{ |x| x + '/**/*.{nib,storyboardc,momd}' })) + paths.each do |p| next if File.extname(p) == ".nib" && !File.exist?(p.sub(/\.nib$/, ".xib")) App.info 'Delete', p rm_rf p + if File.exist?(p) + # It can happen that because of file permissions a dir/file is not + # actually removed, which can lead to confusing issues. + App.fail "Failed to remove `#{p}'. Please remove this path manually." + end end + App.config.vendor_projects.each { |vendor| vendor.clean } end namespace :clean do diff --git a/lib/motion/project/vendor.rb b/lib/motion/project/vendor.rb index 95cf0121..fb9fc507 100644 --- a/lib/motion/project/vendor.rb +++ b/lib/motion/project/vendor.rb @@ -52,6 +52,11 @@ module Motion; module Project; if File.exist?(build_dir) App.info 'Delete', build_dir FileUtils.rm_rf build_dir + if File.exist?(build_dir) + # It can happen that because of file permissions a dir/file is not + # actually removed, which can lead to confusing issues. + App.fail "Failed to remove `#{build_dir}'. Please remove this path manually." + end end end end