mirror of
https://github.com/mas-cli/mas
synced 2025-03-06 23:57:21 +00:00
Revert SoftwareMapAppLibrary.swift
to a class.
Partial #696 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
b9de23aa2a
commit
e68ef510e0
1 changed files with 13 additions and 6 deletions
|
@ -10,17 +10,24 @@ import CommerceKit
|
|||
import ScriptingBridge
|
||||
|
||||
/// Utility for managing installed apps.
|
||||
struct SoftwareMapAppLibrary: AppLibrary {
|
||||
class SoftwareMapAppLibrary: AppLibrary {
|
||||
/// CommerceKit's singleton manager of installed software.
|
||||
private let softwareMap: SoftwareMap
|
||||
|
||||
/// Array of installed software products.
|
||||
let installedApps: [SoftwareProduct]
|
||||
lazy var installedApps = softwareMap.allSoftwareProducts()
|
||||
.filter { product in
|
||||
product.bundlePath.starts(with: "/Applications/")
|
||||
}
|
||||
|
||||
/// Internal initializer for providing a mock software map.
|
||||
/// - Parameter softwareMap: SoftwareMap to use
|
||||
init(softwareMap: SoftwareMap = CKSoftwareMap.shared()) {
|
||||
installedApps = softwareMap.allSoftwareProducts()
|
||||
.filter { product in
|
||||
product.bundlePath.starts(with: "/Applications/")
|
||||
}
|
||||
self.softwareMap = softwareMap
|
||||
}
|
||||
|
||||
deinit {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// Uninstalls all apps located at any of the elements of `appPaths`.
|
||||
|
|
Loading…
Add table
Reference in a new issue