From e38a055f8dd076cc8cc3db4d56f1171d274e36b9 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Mon, 15 Apr 2013 20:22:26 +0200 Subject: refactored error handling, less error prone --- src/luarocks/build/builtin.lua | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 3d179b34..9d97d58b 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -217,8 +217,7 @@ function run(rockspec) end ok = compile_object(object, source, info.defines, info.incdirs) if not ok then - err = "Failed compiling object "..object - break + return nil, "Failed compiling object "..object end table.insert(objects, object) end @@ -231,30 +230,22 @@ function run(rockspec) built_modules[module_name] = dest ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) if not ok then - err = "Failed compiling module "..module_name - break + return nil, "Failed compiling module "..module_name end end end - if ok then - for name, dest in pairs(built_modules) do - fs.make_dir(dest) - ok = fs.copy(name, dest) - if not ok then - err = "Failed installing "..name.." in "..dest - break - end + for name, dest in pairs(built_modules) do + fs.make_dir(dest) + ok = fs.copy(name, dest) + if not ok then + return nil, "Failed installing "..name.." in "..dest end end - if ok then - if fs.is_dir("lua") then - ok, err = fs.copy_contents("lua", luadir) - if not ok then err = "Failed copying contents of 'lua' directory: "..err end + if fs.is_dir("lua") then + ok, err = fs.copy_contents("lua", luadir) + if not ok then + return nil, "Failed copying contents of 'lua' directory: "..err end end - if ok then - return true - else - return nil, err - end + return true end -- cgit v1.2.3-55-g6feb From 1bab385c2ce4f37f808774540c6fe3b46afdda68 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Sat, 20 Apr 2013 12:08:10 +0200 Subject: Accidental workaround was left behind --- src/luarocks/fs/win32/tools.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index c563b137..033f71be 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua @@ -146,8 +146,7 @@ end -- plus an error message. function copy_contents(src, dest) assert(src and dest) - if fs.execute_string(fs.quiet("xcopy "..src.."\\*.* "..fs.Q(dest).." /S/E/Y")) then - --if fs.execute_string(fs.quiet(vars.CP.." -a "..src.."\\*.* "..fs.Q(dest))) then + if fs.execute_string(fs.quiet(vars.CP.." -a "..src.."\\*.* "..fs.Q(dest))) then return true else return false, "Failed copying "..src.." to "..dest -- cgit v1.2.3-55-g6feb