diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2025-02-21 12:29:18 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2025-02-21 13:17:20 -0300 |
| commit | 91dc933e27562c980723d0f6fba3406ef703f187 (patch) | |
| tree | 24ba5982106927ad0f890874237a0a5230466512 /src | |
| parent | 33ff7412d3ddb107a5f81a4c501fcb61ca0e083c (diff) | |
| download | luarocks-91dc933e27562c980723d0f6fba3406ef703f187.tar.gz luarocks-91dc933e27562c980723d0f6fba3406ef703f187.tar.bz2 luarocks-91dc933e27562c980723d0f6fba3406ef703f187.zip | |
core.path: more thorough error checking
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/core/path.lua | 11 | ||||
| -rw-r--r-- | src/luarocks/core/path.tl | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/luarocks/core/path.lua b/src/luarocks/core/path.lua index 2d267e30..2bfe84e0 100644 --- a/src/luarocks/core/path.lua +++ b/src/luarocks/core/path.lua | |||
| @@ -13,11 +13,20 @@ local dir_sep = package.config:sub(1, 1) | |||
| 13 | function path.rocks_dir(tree) | 13 | function path.rocks_dir(tree) |
| 14 | if tree == nil then | 14 | if tree == nil then |
| 15 | tree = cfg.root_dir | 15 | tree = cfg.root_dir |
| 16 | if tree == nil then | ||
| 17 | error("root_dir could not be determined in configuration") | ||
| 18 | end | ||
| 16 | end | 19 | end |
| 17 | if type(tree) == "string" then | 20 | if type(tree) == "string" then |
| 18 | return dir.path(tree, cfg.rocks_subdir) | 21 | return dir.path(tree, cfg.rocks_subdir) |
| 19 | end | 22 | end |
| 20 | return tree.rocks_dir or dir.path(tree.root, cfg.rocks_subdir) | 23 | if tree.rocks_dir then |
| 24 | return tree.rocks_dir | ||
| 25 | end | ||
| 26 | if tree.root and cfg.rocks_subdir then | ||
| 27 | return dir.path(tree.root, cfg.rocks_subdir) | ||
| 28 | end | ||
| 29 | error("invalid configuration for local repository") | ||
| 21 | end | 30 | end |
| 22 | 31 | ||
| 23 | 32 | ||
diff --git a/src/luarocks/core/path.tl b/src/luarocks/core/path.tl index 680c3296..cb5d14dc 100644 --- a/src/luarocks/core/path.tl +++ b/src/luarocks/core/path.tl | |||
| @@ -13,11 +13,20 @@ local dir_sep = package.config:sub(1, 1) | |||
| 13 | function path.rocks_dir(tree: string | Tree): string | 13 | function path.rocks_dir(tree: string | Tree): string |
| 14 | if tree == nil then | 14 | if tree == nil then |
| 15 | tree = cfg.root_dir | 15 | tree = cfg.root_dir |
| 16 | if tree == nil then | ||
| 17 | error("root_dir could not be determined in configuration") | ||
| 18 | end | ||
| 16 | end | 19 | end |
| 17 | if tree is string then | 20 | if tree is string then |
| 18 | return dir.path(tree, cfg.rocks_subdir) | 21 | return dir.path(tree, cfg.rocks_subdir) |
| 19 | end | 22 | end |
| 20 | return tree.rocks_dir or dir.path(tree.root, cfg.rocks_subdir) | 23 | if tree.rocks_dir then |
| 24 | return tree.rocks_dir | ||
| 25 | end | ||
| 26 | if tree.root and cfg.rocks_subdir then | ||
| 27 | return dir.path(tree.root, cfg.rocks_subdir) | ||
| 28 | end | ||
| 29 | error("invalid configuration for local repository") | ||
| 21 | end | 30 | end |
| 22 | 31 | ||
| 23 | --- Produce a versioned version of a filename. | 32 | --- Produce a versioned version of a filename. |
