diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-09-07 01:10:48 +0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-09-07 02:42:15 +0300 |
| commit | 3a9c57a3bbf9db4c668b79bd83198f7372dbb310 (patch) | |
| tree | 7f3ba86a73d7440ef76e716a1edeeea5ec564e83 | |
| parent | 8e48c42e9565f23d2eebbd77027da32e0a86da18 (diff) | |
| download | luarocks-3a9c57a3bbf9db4c668b79bd83198f7372dbb310.tar.gz luarocks-3a9c57a3bbf9db4c668b79bd83198f7372dbb310.tar.bz2 luarocks-3a9c57a3bbf9db4c668b79bd83198f7372dbb310.zip | |
init: add --reset option
This allows for easier switching between Lua versions in a
project directory.
| -rw-r--r-- | src/luarocks/cmd/init.lua | 18 | ||||
| -rw-r--r-- | src/luarocks/util.lua | 1 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/luarocks/cmd/init.lua b/src/luarocks/cmd/init.lua index 8f76d06c..e2dddc09 100644 --- a/src/luarocks/cmd/init.lua +++ b/src/luarocks/cmd/init.lua | |||
| @@ -15,6 +15,11 @@ init.help = [[ | |||
| 15 | <name> is the project name. | 15 | <name> is the project name. |
| 16 | <version> is an optional project version. | 16 | <version> is an optional project version. |
| 17 | 17 | ||
| 18 | --reset Regenerate .luarocks/config-5.x.lua and ./lua wrapper | ||
| 19 | if those already exist. | ||
| 20 | |||
| 21 | Options for specifying rockspec data: | ||
| 22 | |||
| 18 | --license="<string>" A license string, such as "MIT/X11" or "GNU GPL v3". | 23 | --license="<string>" A license string, such as "MIT/X11" or "GNU GPL v3". |
| 19 | --summary="<txt>" A short one-line description summary. | 24 | --summary="<txt>" A short one-line description summary. |
| 20 | --detailed="<txt>" A longer description string. | 25 | --detailed="<txt>" A longer description string. |
| @@ -127,8 +132,19 @@ function init.command(flags, name, version) | |||
| 127 | end | 132 | end |
| 128 | 133 | ||
| 129 | local lua_wrapper = "./lua" .. ext | 134 | local lua_wrapper = "./lua" .. ext |
| 135 | |||
| 136 | if flags["reset"] then | ||
| 137 | fs.delete(lua_wrapper) | ||
| 138 | for v in util.lua_versions() do | ||
| 139 | if v ~= cfg.lua_version then | ||
| 140 | local config_file = dir.path(".luarocks", "config-"..v..".lua") | ||
| 141 | fs.move(config_file, config_file .. "~") | ||
| 142 | end | ||
| 143 | end | ||
| 144 | end | ||
| 145 | |||
| 130 | if not fs.exists(lua_wrapper) then | 146 | if not fs.exists(lua_wrapper) then |
| 131 | util.printout("Preparing " .. lua_wrapper .. " ...") | 147 | util.printout("Preparing " .. lua_wrapper .. " for version " .. cfg.lua_version .. "...") |
| 132 | path.use_tree(tree) | 148 | path.use_tree(tree) |
| 133 | fs.wrap_script(nil, "lua", "all") | 149 | fs.wrap_script(nil, "lua", "all") |
| 134 | else | 150 | else |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 4be7d71e..3d8f9738 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
| @@ -139,6 +139,7 @@ local supported_flags = { | |||
| 139 | ["porcelain"] = true, | 139 | ["porcelain"] = true, |
| 140 | ["project-tree"] = "<tree>", | 140 | ["project-tree"] = "<tree>", |
| 141 | ["quick"] = true, | 141 | ["quick"] = true, |
| 142 | ["reset"] = true, | ||
| 142 | ["rock-dir"] = true, | 143 | ["rock-dir"] = true, |
| 143 | ["rock-license"] = true, | 144 | ["rock-license"] = true, |
| 144 | ["rock-namespace"] = true, | 145 | ["rock-namespace"] = true, |
