diff options
author | ubq323 <ubq323@ubq323.website> | 2024-03-30 21:28:22 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-03-30 21:28:22 +0000 |
commit | 4d5d6c4cb4b523f218941dc43f0aacf5074c4dc8 (patch) | |
tree | bc2d8f18d96f67b1297e0254d8ca3794b153e4e9 | |
parent | 2748e1876b0c9240f263acdd2b2583daab861c73 (diff) |
pm tells if required
-rw-r--r-- | pm.lua | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -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 |