diff options
| author | ruki <[email protected]> | 2021-02-13 00:39:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-02-13 00:39:27 +0800 |
| commit | 5d26d21e31b9ba443208f1f027b5ac8b6cdc44df (patch) | |
| tree | 94eab07b083797ef561102759679a1893cee0511 /xmake/modules/private/action/require/impl/uninstall_packages.lua | |
| parent | e66d6878040a80e6512db851750185b8ab35b127 (diff) | |
split impl.package
Diffstat (limited to 'xmake/modules/private/action/require/impl/uninstall_packages.lua')
| -rw-r--r-- | xmake/modules/private/action/require/impl/uninstall_packages.lua | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/xmake/modules/private/action/require/impl/uninstall_packages.lua b/xmake/modules/private/action/require/impl/uninstall_packages.lua new file mode 100644 index 000000000..a5185f868 --- /dev/null +++ b/xmake/modules/private/action/require/impl/uninstall_packages.lua @@ -0,0 +1,47 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file uninstall_packages.lua +-- + +-- imports +import("core.cache.localcache") +import("private.action.require.impl.package") + +-- uninstall packages +function main(requires, opt) + + -- init options + opt = opt or {} + + -- do not remove dependent packages + opt.nodeps = true + + -- clear the local cache + localcache.clear() + + -- remove all packages + local packages = {} + for _, instance in ipairs(package.load_packages(requires, opt)) do + if os.isfile(instance:manifest_file()) then + table.insert(packages, instance) + end + os.tryrm(instance:installdir()) + end + return packages +end + |
