summaryrefslogtreecommitdiff
path: root/pm.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-03-30 21:28:22 +0000
committerubq323 <ubq323@ubq323.website>2024-03-30 21:28:22 +0000
commit4d5d6c4cb4b523f218941dc43f0aacf5074c4dc8 (patch)
treebc2d8f18d96f67b1297e0254d8ca3794b153e4e9 /pm.lua
parent2748e1876b0c9240f263acdd2b2583daab861c73 (diff)
pm tells if required
Diffstat (limited to 'pm.lua')
-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