diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-04-12 17:36:29 +0200 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-04-12 17:36:29 +0200 |
commit | 9cb1ccaeafb02c48d1aa87e746b1d2716454485f (patch) | |
tree | c615112bd95041b99a7ee6bf0517c0080ce53b7f /src | |
parent | 8e2d4cad8d01916c3cb5638896c3ced4929d115e (diff) | |
download | luarocks-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.lua | 27 |
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. |
5 | module("luarocks.fs.win32.tools", package.seeall) | 5 | module("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 | |||
7 | local fs = require("luarocks.fs") | 12 | local fs = require("luarocks.fs") |
8 | local dir = require("luarocks.dir") | 13 | local dir = require("luarocks.dir") |
9 | local cfg = require("luarocks.cfg") | 14 | local cfg = require("luarocks.cfg") |
10 | 15 | ||
11 | local dir_stack = {} | 16 | local dir_stack = {} |
12 | 17 | ||
13 | local vars = cfg.variables | 18 | local vars = cfg.variables |
14 | 19 | ||
20 | local function pack(...) | ||
21 | return { n = select("#", ...), ... } | ||
22 | end | ||
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. |
53 | function execute_string(cmd) | 62 | function 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. |
134 | function copy_contents(src, dest) | 152 | function 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 |