Improvements, adding error raising to handle break the build if something fails

This commit is contained in:
eriknyk
2014-07-22 15:06:57 -04:00
parent e8403738f7
commit 7ad638b98d

View File

@@ -13,10 +13,16 @@ task :required do
puts "JSON gem not found.\nInstall it by running 'gem install json'"
exit(1)
end
begin
require 'ftools'
rescue LoadError
puts "JSON gem not found.\nInstall it by running 'gem install ftools'"
exit(1)
end
end
desc "Copy Files to ProcessMaker"
desc "Build Front-End for ProcessMaker"
task :build => [:required] do
mode = "production"
#argv1 = ARGV.last
@@ -225,17 +231,23 @@ def buildMafe(homeDir, targetDir, mode)
end
def prepareDirs(dirs)
homeDir = Dir.pwd
puts "Preparing Directories..."
dirs.each do |dir|
if File.directory?(dir)
puts "Removing #{dir}"
system "rm -rf #{dir}"
if !File.writable?(dir)
raise "Error, directory " + dir + " is not writable."
end
FileUtils.rm_rf(dir)
end
begin
puts 'create '.green + dir
FileUtils.mkdir_p(dir)
rescue Exception => e
puts ' (failed)'.red
raise RuntimeError, e.message
end
#Dir.mkdir(dir)
system("mkdir -p #{dir}")
end
end
@@ -266,23 +278,18 @@ end
def executeInto(path, tasks)
Dir.chdir(path) do
tasks.each do |task|
system "rake #{task}"
tasks.each do |task|
system "rake #{task}" or raise "An error was raised executing task '#{task}' into #{path}".red
end
end
end
end
def copyFiles(files)
files.each do |from, to|
print " Copy ".green + from.gsub(Dir.pwd+'/vendor/colosa/', '')+' -> '.brown+to.gsub(Dir.pwd, '').gray
system('cp -Rf '+from+' '+to+' 2>&1')
puts " copy ".green + from.gsub(Dir.pwd+'/vendor/colosa/', '')
puts ' into '.green + to.gsub(Dir.pwd, '')
if $? == 0
puts " (ok)".green
else
puts " (failed)".red
end
system('cp -Rf '+from+' '+to+' 2>&1') or raise "Can't copy into directory #{to}".red
end
end