summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pm.lua26
1 files changed, 21 insertions, 5 deletions
diff --git a/pm.lua b/pm.lua
index abeb056..b63c2bc 100644
--- a/pm.lua
+++ b/pm.lua
@@ -2,6 +2,21 @@
local rbase = "https://g.gh0.pw/ccprogs/plain/"
+local function is_required()
+ local n = 0
+ local res = false
+ while true do
+ local x = debug.getinfo(n)
+ if x == nil then break end
+ n = n + 1
+ if x.func == require then
+ res = true
+ break
+ end
+ end
+ return res
+end
+
local function perr(err,what)
if err then error(what..": "..err) end
end
@@ -115,9 +130,10 @@ local function dl(pkgname)
print"done"
end
-
---return {manifest=manifest,rd=recursive_depsof,rf=recursive_filesof,dl=dl,cc=clear_cache}
-
-for i=1,#arg do
- dl(arg[i])
+if is_required() then
+ return {manifest=manifest,rd=recursive_depsof,rf=recursive_filesof,dl=dl,cc=clear_cache}
+else
+ for i=1,#arg do
+ dl(arg[i])
+ end
end