diff options
| author | ruki <[email protected]> | 2026-08-09 23:45:48 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-08-09 23:45:48 +0800 |
| commit | 6f2617cbdf2ba77ba424507941a50fda8d64e0b9 (patch) | |
| tree | e14c0b857629e8b59d187b5c8e185aea4ecef8e8 /xmake/actions/addon/main.lua | |
| parent | c7172a3a0cce98e395567202e732ebb86b475360 (diff) | |
improve addon.register
Diffstat (limited to 'xmake/actions/addon/main.lua')
| -rw-r--r-- | xmake/actions/addon/main.lua | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/xmake/actions/addon/main.lua b/xmake/actions/addon/main.lua index 722cdd52d..b99df4fe0 100644 --- a/xmake/actions/addon/main.lua +++ b/xmake/actions/addon/main.lua @@ -94,11 +94,20 @@ function _install_from_local(dir, name) for _, payloaddir in ipairs(addon.payloads_of(payloadroot)) do os.vcp(path.join(payloadroot, payloaddir), path.join(dstdir, payloaddir)) end - local ok, errors = addon.register(name, LOCALVERSION) - if not ok then - os.tryrm(dstdir) - raise(errors) - end + -- we need to roll back the installed payloads if it cannot be registered, e.g. the name conflicts + try + { + function () + addon.register(name, LOCALVERSION) + end, + catch + { + function (errors) + os.tryrm(dstdir) + raise(errors) + end + } + } cprint("${color.success}install ${bright}%s${clear} ok!", name) end |
