diff options
| author | ruki <[email protected]> | 2023-11-17 22:31:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-11-17 22:31:31 +0800 |
| commit | 02c004d42d70979f3ca983dd960291761800e2a6 (patch) | |
| tree | a4ce4eb532be9d9fbf8e90cbe45524170d7435e5 /xmake/modules | |
| parent | bd74082ad5740e0b97ffe237216dd533eb3d0383 (diff) | |
improve os.rm to support remove emptydirs
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/action/clean/remove_files.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/private/utils/batchcmds.lua | 6 |
2 files changed, 4 insertions, 12 deletions
diff --git a/xmake/modules/private/action/clean/remove_files.lua b/xmake/modules/private/action/clean/remove_files.lua index 606bb405d..3d62c6b78 100644 --- a/xmake/modules/private/action/clean/remove_files.lua +++ b/xmake/modules/private/action/clean/remove_files.lua @@ -25,14 +25,6 @@ import("core.base.option") function main(filedirs, opt) opt = opt or {} for _, filedir in ipairs(filedirs) do - os.tryrm(filedir) - if option.get("all") or opt.emptydir then - -- remove it if the parent directory is empty - local parentdir = path.directory(filedir) - while parentdir and os.isdir(parentdir) and os.emptydir(parentdir) do - os.tryrm(parentdir) - parentdir = path.directory(parentdir) - end - end + os.tryrm(filedir, {emptydirs = option.get("all") or opt.emptydir}) end end diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua index cbe924f53..0000b7111 100644 --- a/xmake/modules/private/utils/batchcmds.lua +++ b/xmake/modules/private/utils/batchcmds.lua @@ -140,7 +140,7 @@ end function _runcmd_rm(cmd, opt) local filepath = cmd.filepath if not opt.dryrun then - os.tryrm(filepath) + os.tryrm(filepath, opt) end end @@ -148,7 +148,7 @@ end function _runcmd_tryrm(cmd, opt) local filepath = cmd.filepath if not opt.dryrun then - os.tryrm(filepath) + os.tryrm(filepath, opt) end end @@ -156,7 +156,7 @@ end function _runcmd_rmdir(cmd, opt) local dir = cmd.dir if not opt.dryrun and os.isdir(dir) then - os.tryrm(dir) + os.tryrm(dir, opt) end end |
