From 2181a1b29cf8e2dd54988c7fe37ba7a07f6ef92d Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 3 Mar 2014 17:50:33 -0300 Subject: Revert change that broke rocks.moonscript.org — it would skip servers that have no .zip manifest in them. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/luarocks/manif.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 951d6e56..99702b46 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua @@ -131,7 +131,7 @@ function load_manifest(repo_url) local err, errcode for _, filename in ipairs(filenames) do pathname, err, errcode = fetch_manifest_from(repo_url, filename) - if pathname or errcode == "network" then + if pathname then break end end -- cgit v1.2.3-55-g6feb From 3aa7e7a08f0dd756e31ce34e4c9ae9bf0169d49a Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 20 Mar 2014 13:54:07 -0300 Subject: Bring the Unix implementation up to par with the Windows one! --- src/luarocks/fs/unix/tools.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index df2eee3f..1f4f2a4e 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua @@ -18,9 +18,13 @@ end -- Uses the module's internal directory stack. -- @return string: the absolute pathname of the current directory. function current_dir() - local pipe = io.popen(vars.PWD) - local current = pipe:read("*l") - pipe:close() + local current = cfg.cache_pwd + if not current then + local pipe = io.popen(fs.Q(vars.PWD)) + current = pipe:read("*l") + pipe:close() + cfg.cache_pwd = current + end for _, directory in ipairs(dir_stack) do current = fs.absolute_name(directory, current) end @@ -33,7 +37,7 @@ end -- @return boolean: true if command succeeds (status code 0), false -- otherwise. function execute_string(cmd) - local code = os.execute(command_at(fs.current_dir(), cmd)) + local code, err = os.execute(command_at(fs.current_dir(), cmd)) if code == 0 or code == true then return true else -- cgit v1.2.3-55-g6feb From 397659cc5cb30569b33cc9c0ab220f85379bc97f Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 20 Mar 2014 16:49:51 -0300 Subject: Split luarocks.path the library and `luarocks path` the command. As suggested in #232. --- src/bin/luarocks | 3 +-- src/luarocks/path.lua | 40 ------------------------------------- src/luarocks/path_cmd.lua | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 src/luarocks/path_cmd.lua (limited to 'src') diff --git a/src/bin/luarocks b/src/bin/luarocks index e9cfc349..1d81ed1e 100755 --- a/src/bin/luarocks +++ b/src/bin/luarocks @@ -1,5 +1,4 @@ #!/usr/bin/env lua - local loader = require("luarocks.loader") local command_line = require("luarocks.command_line") @@ -16,7 +15,7 @@ commands = { remove = "luarocks.remove", make = "luarocks.make", download = "luarocks.download", - path = "luarocks.path", + path = "luarocks.path_cmd", show = "luarocks.show", new_version = "luarocks.new_version", lint = "luarocks.lint", diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index d7273095..200829d0 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua @@ -7,7 +7,6 @@ module("luarocks.path", package.seeall) local dir = require("luarocks.dir") local cfg = require("luarocks.cfg") local util = require("luarocks.util") -local deps = require("luarocks.deps") help_summary = "Return the currently configured package path." help_arguments = "" @@ -390,42 +389,3 @@ function which(module_name, filename, name, version, tree, manifest) assert(false) end ---- Driver function for "path" command. --- @return boolean This function always succeeds. -function run(...) - local flags = util.parse_flags(...) - local deps_mode = deps.get_deps_mode(flags) - - local lr_path, lr_cpath = cfg.package_paths() - local bin_dirs = map_trees(deps_mode, deploy_bin_dir) - - if flags["lr-path"] then - util.printout(util.remove_path_dupes(lr_path, ';')) - return true - elseif flags["lr-cpath"] then - util.printout(util.remove_path_dupes(lr_cpath, ';')) - return true - elseif flags["lr-bin"] then - local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) - util.printout(util.remove_path_dupes(lr_bin, ';')) - return true - end - - if flags["append"] then - lr_path = package.path .. ";" .. lr_path - lr_cpath = package.cpath .. ";" .. lr_cpath - else - lr_path = lr_path.. ";" .. package.path - lr_cpath = lr_cpath .. ";" .. package.cpath - end - - util.printout(cfg.export_lua_path:format(util.remove_path_dupes(lr_path, ';'))) - util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(lr_cpath, ';'))) - if flags["bin"] then - table.insert(bin_dirs, 1, os.getenv("PATH")) - local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) - util.printout(cfg.export_path:format(lr_bin)) - end - return true -end - diff --git a/src/luarocks/path_cmd.lua b/src/luarocks/path_cmd.lua new file mode 100644 index 00000000..4df51e2d --- /dev/null +++ b/src/luarocks/path_cmd.lua @@ -0,0 +1,50 @@ + +--- @module luarocks.path_cmd +-- Driver for the `luarocks path` command. +local path_cmd = {} + +local util = require("luarocks.util") +local deps = require("luarocks.deps") +local cfg = require("luarocks.cfg") +local path = require("luarocks.path") + +--- Driver function for "path" command. +-- @return boolean This function always succeeds. +function path_cmd.run(...) + local flags = util.parse_flags(...) + local deps_mode = deps.get_deps_mode(flags) + + local lr_path, lr_cpath = cfg.package_paths() + local bin_dirs = path.map_trees(deps_mode, path.deploy_bin_dir) + + if flags["lr-path"] then + util.printout(util.remove_path_dupes(lr_path, ';')) + return true + elseif flags["lr-cpath"] then + util.printout(util.remove_path_dupes(lr_cpath, ';')) + return true + elseif flags["lr-bin"] then + local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) + util.printout(util.remove_path_dupes(lr_bin, ';')) + return true + end + + if flags["append"] then + lr_path = package.path .. ";" .. lr_path + lr_cpath = package.cpath .. ";" .. lr_cpath + else + lr_path = lr_path.. ";" .. package.path + lr_cpath = lr_cpath .. ";" .. package.cpath + end + + util.printout(cfg.export_lua_path:format(util.remove_path_dupes(lr_path, ';'))) + util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(lr_cpath, ';'))) + if flags["bin"] then + table.insert(bin_dirs, 1, os.getenv("PATH")) + local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) + util.printout(cfg.export_path:format(lr_bin)) + end + return true +end + +return path_cmd -- cgit v1.2.3-55-g6feb