diff options
| author | rubenwardy <rw@rubenwardy.com> | 2022-08-15 09:08:24 +0100 |
|---|---|---|
| committer | rubenwardy <rw@rubenwardy.com> | 2022-08-15 21:19:24 +0100 |
| commit | adc89f7977ae4b1e86cb413fb52406865150b064 (patch) | |
| tree | 619260b5676c5a4a46f67a11cae0718a63b0a0c9 /builtin/mainmenu/pkgmgr.lua | |
| parent | db612c10ee5405c42ebf7a0f74d0decfbf507de3 (diff) | |
| download | minetest-adc89f7977ae4b1e86cb413fb52406865150b064.tar.xz | |
Add unit tests for pkgmgr.install_dir
Diffstat (limited to 'builtin/mainmenu/pkgmgr.lua')
| -rw-r--r-- | builtin/mainmenu/pkgmgr.lua | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua index 3028295c8..9fa9aebb0 100644 --- a/builtin/mainmenu/pkgmgr.lua +++ b/builtin/mainmenu/pkgmgr.lua @@ -244,11 +244,7 @@ end -------------------------------------------------------------------------------- function pkgmgr.is_valid_modname(modpath) - if modpath:find("-") ~= nil then - return false - end - - return true + return modpath:match("[^a-z0-9_]") == nil end -------------------------------------------------------------------------------- @@ -521,6 +517,8 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath) local basefolder = pkgmgr.get_base_folder(path) if expected_type == "txp" then + assert(basename) + -- There's no good way to detect a texture pack, so let's just assume -- it's correct for now. if basefolder and basefolder.type ~= "invalid" and basefolder.type ~= "txp" then @@ -544,7 +542,7 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath) -- Check type if basefolder.type ~= expected_type and (basefolder.type ~= "modpack" or expected_type ~= "mod") then - return nil, fgettext("Unable to install a $1 as a $1", basefolder.type, expected_type) + return nil, fgettext("Unable to install a $1 as a $2", basefolder.type, expected_type) end -- Set targetpath if not predetermined |
