Skip to content

Commit

Permalink
Implement --lazy, --upgrade, --upgrade-deps, --reinstall-deps
Browse files Browse the repository at this point in the history
Only for the install command for now.
  • Loading branch information
mpeterv committed Jan 6, 2016
1 parent 792d497 commit 7bea12f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/luarocks/install.lua
Expand Up @@ -22,6 +22,12 @@ install.help = [[
Argument may be the name of a rock to be fetched from a repository
or a filename of a locally available rock.
--lazy Do not install a rock by name if it's
already installed.
--upgrade Do not install a rock by name if its
latest version is already installed.
--upgrade-deps Recursively upgrade dependencies of the rock.
--reinstall-deps Recursively reinstall dependencies of the rock.
--keep Do not remove previously installed versions of the
rock after installing a new one. This behavior can
be made permanent by setting keep_other_versions=true
Expand Down Expand Up @@ -270,6 +276,18 @@ function install.run(...)
local ok, err = fs.check_command_permissions(flags)
if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end

if flags.upgrade then
flags.install_mode = "upgrade"
elseif flags.lazy then
flags.install_mode = "satisfy"
end

if flags["upgrade-deps"] then
flags.deps_install_mode = "upgrade"
elseif flags["reinstall-deps"] then
flags.deps_install_mode = "install"
end

if name:match("%.rockspec$") or name:match("%.src%.rock$") or name:match("%.rock") then
return install.install_by_url(name, flags)
else
Expand Down
4 changes: 4 additions & 0 deletions src/luarocks/util.lua
Expand Up @@ -87,6 +87,7 @@ local supported_flags = {
["home"] = true,
["homepage"] = "\"<url>\"",
["keep"] = true,
["lazy"] = true,
["lib"] = "<library>",
["license"] = "\"<text>\"",
["list"] = true,
Expand Down Expand Up @@ -114,6 +115,7 @@ local supported_flags = {
["pack-binary-rock"] = true,
["porcelain"] = true,
["quick"] = true,
["reinstall-deps"] = true,
["rock-dir"] = true,
["rock-tree"] = true,
["rock-trees"] = true,
Expand All @@ -128,6 +130,8 @@ local supported_flags = {
["timeout"] = "<seconds>",
["to"] = "<path>",
["tree"] = "<path>",
["upgrade"] = true,
["upgrade-deps"] = true,
["user-config"] = true,
["verbose"] = true,
["version"] = true,
Expand Down

0 comments on commit 7bea12f

Please sign in to comment.