aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2013-04-12 17:36:29 +0200
committerThijs Schreijer <thijs@thijsschreijer.nl>2013-04-12 17:36:29 +0200
commit9cb1ccaeafb02c48d1aa87e746b1d2716454485f (patch)
treec615112bd95041b99a7ee6bf0517c0080ce53b7f /src
parent8e2d4cad8d01916c3cb5638896c3ced4929d115e (diff)
downloadluarocks-9cb1ccaeafb02c48d1aa87e746b1d2716454485f.tar.gz
luarocks-9cb1ccaeafb02c48d1aa87e746b1d2716454485f.tar.bz2
luarocks-9cb1ccaeafb02c48d1aa87e746b1d2716454485f.zip
added some verbose output options. TODO: make commandline option
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/fs/win32/tools.lua27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua
index 3e7ebd32..e32b8280 100644
--- a/src/luarocks/fs/win32/tools.lua
+++ b/src/luarocks/fs/win32/tools.lua
@@ -4,14 +4,23 @@
4-- used by this module. 4-- used by this module.
5module("luarocks.fs.win32.tools", package.seeall) 5module("luarocks.fs.win32.tools", package.seeall)
6 6
7
8--uncomment following line to make executed commands and results visible
9--TODO: make commandline option
10--local verbose = true
11
7local fs = require("luarocks.fs") 12local fs = require("luarocks.fs")
8local dir = require("luarocks.dir") 13local dir = require("luarocks.dir")
9local cfg = require("luarocks.cfg") 14local cfg = require("luarocks.cfg")
10 15
11local dir_stack = {} 16local dir_stack = {}
12 17
13local vars = cfg.variables 18local vars = cfg.variables
14 19
20local function pack(...)
21 return { n = select("#", ...), ... }
22end
23
15--- Strip the last extension of a filename. 24--- Strip the last extension of a filename.
16-- Example: "foo.tar.gz" becomes "foo.tar". 25-- Example: "foo.tar.gz" becomes "foo.tar".
17-- If filename has no dots, returns it unchanged. 26-- If filename has no dots, returns it unchanged.
@@ -51,8 +60,17 @@ end
51-- @return boolean: true if command succeeds (status code 0), false 60-- @return boolean: true if command succeeds (status code 0), false
52-- otherwise. 61-- otherwise.
53function execute_string(cmd) 62function execute_string(cmd)
54 local code = os.execute(command_at(fs.current_dir(), cmd)) 63 cmd = command_at(fs.current_dir(), cmd)
55 if code == 0 or code == true then 64 if verbose then print("Executing: "..tostring(cmd)) end
65 local code = pack(os.execute(cmd))
66 if verbose then
67 print("Results: "..tostring(code.n))
68 for i = 1,code.n do
69 print(" "..tostring(i).." ("..type(code[i]).."): "..tostring(code[i]))
70 end
71 print()
72 end
73 if code[1] == 0 or code[1] == true then
56 return true 74 return true
57 else 75 else
58 return false 76 return false
@@ -133,7 +151,8 @@ end
133-- plus an error message. 151-- plus an error message.
134function copy_contents(src, dest) 152function copy_contents(src, dest)
135 assert(src and dest) 153 assert(src and dest)
136 if fs.execute_string(fs.quiet(vars.CP.." -a "..src.."\\*.* "..fs.Q(dest))) then 154 if fs.execute_string(fs.quiet("xcopy "..src.."\\*.* "..fs.Q(dest).." /S/E/Y")) then
155 --if fs.execute_string(fs.quiet(vars.CP.." -a "..src.."\\*.* "..fs.Q(dest))) then
137 return true 156 return true
138 else 157 else
139 return false, "Failed copying "..src.." to "..dest 158 return false, "Failed copying "..src.." to "..dest