aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordwenegar <simone.livieri@gmail.com>2019-07-18 08:31:43 +0900
committerHisham Muhammad <hisham@gobolinux.org>2019-07-17 20:31:43 -0300
commit56a90dbb0bdc7db59857301427825e5a7fc2900f (patch)
tree88a2f64acb177a0960b1884036165777486ef827
parent12bdbc927721f0b12db20c5ba0612c78bb670376 (diff)
downloadluarocks-56a90dbb0bdc7db59857301427825e5a7fc2900f.tar.gz
luarocks-56a90dbb0bdc7db59857301427825e5a7fc2900f.tar.bz2
luarocks-56a90dbb0bdc7db59857301427825e5a7fc2900f.zip
Add `--dir` option to the `new_version` command (#1014)
-rw-r--r--src/luarocks/cmd/new_version.lua17
-rw-r--r--src/luarocks/util.lua1
2 files changed, 15 insertions, 3 deletions
diff --git a/src/luarocks/cmd/new_version.lua b/src/luarocks/cmd/new_version.lua
index f1181d40..19b5fa1e 100644
--- a/src/luarocks/cmd/new_version.lua
+++ b/src/luarocks/cmd/new_version.lua
@@ -8,10 +8,11 @@ local download = require("luarocks.download")
8local fetch = require("luarocks.fetch") 8local fetch = require("luarocks.fetch")
9local persist = require("luarocks.persist") 9local persist = require("luarocks.persist")
10local fs = require("luarocks.fs") 10local fs = require("luarocks.fs")
11local dir = require("luarocks.dir")
11local type_rockspec = require("luarocks.type.rockspec") 12local type_rockspec = require("luarocks.type.rockspec")
12 13
13new_version.help_summary = "Auto-write a rockspec for a new version of a rock." 14new_version.help_summary = "Auto-write a rockspec for a new version of a rock."
14new_version.help_arguments = "[--tag=<tag>] [<package>|<rockspec>] [<new_version>] [<new_url>]" 15new_version.help_arguments = "[--tag=<tag>] [--dir=<path>] [<package>|<rockspec>] [<new_version>] [<new_url>]"
15new_version.help = [[ 16new_version.help = [[
16This is a utility function that writes a new rockspec, updating data 17This is a utility function that writes a new rockspec, updating data
17from a previous one. 18from a previous one.
@@ -34,7 +35,9 @@ the new MD5 checksum.
34If a tag is given, it replaces the one from the old rockspec. If there is 35If a tag is given, it replaces the one from the old rockspec. If there is
35an old tag but no new one passed, it is guessed in the same way URL is. 36an old tag but no new one passed, it is guessed in the same way URL is.
36 37
37WARNING: it writes the new rockspec to the current directory, 38If a directory is not given, it defaults to the current directory.
39
40WARNING: it writes the new rockspec to the given directory,
38overwriting the file if it already exists. 41overwriting the file if it already exists.
39]] 42]]
40 43
@@ -158,6 +161,11 @@ function new_version.command(flags, input, version, url)
158 version = flags.tag:gsub("^v", "") 161 version = flags.tag:gsub("^v", "")
159 end 162 end
160 163
164 local out_dir
165 if flags.dir then
166 out_dir = dir.normalize(flags.dir)
167 end
168
161 if version then 169 if version then
162 new_ver, new_rev = version:match("(.*)%-(%d+)$") 170 new_ver, new_rev = version:match("(.*)%-(%d+)$")
163 new_rev = tonumber(new_rev) 171 new_rev = tonumber(new_rev)
@@ -183,7 +191,10 @@ function new_version.command(flags, input, version, url)
183 end 191 end
184 192
185 local out_filename = out_name.."-"..new_rockver.."-"..new_rev..".rockspec" 193 local out_filename = out_name.."-"..new_rockver.."-"..new_rev..".rockspec"
186 194 if out_dir then
195 out_filename = dir.path(out_dir, out_filename)
196 fs.make_dir(out_dir)
197 end
187 persist.save_from_table(out_filename, out_rs, type_rockspec.order) 198 persist.save_from_table(out_filename, out_rs, type_rockspec.order)
188 199
189 util.printout("Wrote "..out_filename) 200 util.printout("Wrote "..out_filename)
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index 1f7bd484..57cefc61 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -97,6 +97,7 @@ local supported_flags = {
97 ["deps-mode"] = "<mode>", 97 ["deps-mode"] = "<mode>",
98 ["detailed"] = "\"<text>\"", 98 ["detailed"] = "\"<text>\"",
99 ["dev"] = true, 99 ["dev"] = true,
100 ["dir"] = "<path>",
100 ["force"] = true, 101 ["force"] = true,
101 ["force-fast"] = true, 102 ["force-fast"] = true,
102 ["from"] = "<server>", 103 ["from"] = "<server>",