rakelib/extensions.rb
changeset 81 2a1efb99c83d
parent 62 de0e8016c2d5
child 86 f2a7a4378c22
--- a/rakelib/extensions.rb	Tue Nov 22 21:19:13 2016 +0000
+++ b/rakelib/extensions.rb	Thu Nov 24 10:27:37 2016 +0000
@@ -195,9 +195,10 @@
 
 
 module RakeFileUtils
-  # Evaluates given command using a shell. Return true if command
-  # returns zero exit status, false otherwise. If block is given
-  # then block is evaluate with status, stdout and stderr
+  # Evaluates given command using a shell. If block is given
+  # then block is evaluate with status, stdout and stderr.
+  # If no block is given, return true if command is successfull
+  # ot thrown an exception if command fails (its exist status is non-zero)
   #
   # if cwd: keyword is specified, then working directory is changed
   # to specified directory before the command is run.  
@@ -220,11 +221,15 @@
         end
         return status.success?
       else
+        success = false
         chdir(cwd) do                
           fu_output_message (cmd.kind_of?(Array) ? cmd.join(' ') : cmd)
           system(*cmd)
-        end
-        return $?.success?
+          success = $?.success?
+        end        
+        if not success then
+          raise Exception.new("command failed: #{cmd.kind_of?(Array) ? cmd.join(' ') : cmd}")
+        end        
       end
     end
     return true
@@ -251,10 +256,10 @@
         end
         make_objdir('.')
         sh "wine cmd /c #{MAKE} #{args}"
-      else 
+      else         
         sh "#{MAKE} #{args}"
       end
-    else
+    else      
       sh "#{MAKE} #{args}"
     end
   end