aboutsummaryrefslogtreecommitdiff
path: root/lpm.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lpm.lua')
-rw-r--r--lpm.lua31
1 files changed, 22 insertions, 9 deletions
diff --git a/lpm.lua b/lpm.lua
index 80ec805..734eb48 100644
--- a/lpm.lua
+++ b/lpm.lua
@@ -356,6 +356,25 @@ end
local common = {}
+
+function common.split(splitter, str)
+ local o = 1
+ local res = {}
+ while true do
+ local s, e = str:find(splitter, o)
+ table.insert(res, str:sub(o, s and (s - 1) or #str))
+ if not s then break end
+ o = e + 1
+ end
+ return table.unpack(res)
+end
+
+function common.dirname(path)
+ local s = path:reverse():find(PATHSEP)
+ if not s then return path end
+ return path:sub(1, #path - s)
+end
+
function common.rmrf(root)
if not root or root == "" then return end
local info = system.stat(root)
@@ -369,9 +388,9 @@ function common.mkdirp(path)
local stat = system.stat(path)
if stat and stat.type == "dir" then return true end
if stat and stat.type == "file" then error("path " .. path .. " exists") end
+ system.mkdir(path)
local subdirs = {}
while path and path ~= "" do
- system.mkdir(path)
local updir, basedir = path:match("(.*)[/\\](.+)$")
table.insert(subdirs, 1, basedir or path)
path = updir
@@ -390,12 +409,6 @@ function common.basename(path)
end
-function common.dirname(path)
- local s = path:reverse():find(PATHSEP)
- if not s then return path end
- return path:sub(1, #path - s)
-end
-
function common.merge(src, merge)
for k, v in pairs(merge) do src[k] = v end
@@ -1241,9 +1254,9 @@ local function lpm_plugin_uninstall(...)
for i, name in ipairs({ ... }) do
local plugins = { get_plugin(name) }
if #plugins == 0 then error("can't find plugin " .. name) end
- local installed_plugins = common.grep(plugins, function(plugin) return plugin:is_installed() end)
+ local installed_plugins = common.grep(plugins, function(plugin) return plugin:is_installed(system_bottle) end)
if #installed_plugins == 0 then error("plugin " .. name .. " not installed") end
- for i, plugin in ipairs(installed_plugins) do plugin:uninstall() end
+ for i, plugin in ipairs(installed_plugins) do plugin:uninstall(system_bottle) end
end
end