mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-26 15:55:45 +00:00
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import path from "path"
|
|
import os from "os"
|
|
|
|
const home = os.homedir()
|
|
|
|
// macOS directories that trigger TCC (Transparency, Consent, and Control)
|
|
// permission prompts when accessed by a non-sandboxed process.
|
|
const DARWIN_HOME = [
|
|
// Media
|
|
"Music",
|
|
"Pictures",
|
|
"Movies",
|
|
// User-managed folders synced via iCloud / subject to TCC
|
|
"Downloads",
|
|
"Desktop",
|
|
"Documents",
|
|
// Other system-managed
|
|
"Public",
|
|
"Applications",
|
|
"Library",
|
|
]
|
|
|
|
const DARWIN_LIBRARY = [
|
|
"Application Support/AddressBook",
|
|
"Calendars",
|
|
"Mail",
|
|
"Messages",
|
|
"Safari",
|
|
"Cookies",
|
|
"Application Support/com.apple.TCC",
|
|
"PersonalizationPortrait",
|
|
"Metadata/CoreSpotlight",
|
|
"Suggestions",
|
|
]
|
|
|
|
const DARWIN_ROOT = ["/.DocumentRevisions-V100", "/.Spotlight-V100", "/.Trashes", "/.fseventsd"]
|
|
|
|
const WIN32_HOME = ["AppData", "Downloads", "Desktop", "Documents", "Pictures", "Music", "Videos", "OneDrive"]
|
|
|
|
export namespace Protected {
|
|
/** Directory basenames to skip when scanning the home directory. */
|
|
export function names(): ReadonlySet<string> {
|
|
if (process.platform === "darwin") return new Set(DARWIN_HOME)
|
|
if (process.platform === "win32") return new Set(WIN32_HOME)
|
|
return new Set()
|
|
}
|
|
|
|
/** Absolute paths that should never be watched, stated, or scanned. */
|
|
export function paths(): string[] {
|
|
if (process.platform === "darwin")
|
|
return [
|
|
...DARWIN_HOME.map((n) => path.join(home, n)),
|
|
...DARWIN_LIBRARY.map((n) => path.join(home, "Library", n)),
|
|
...DARWIN_ROOT,
|
|
]
|
|
if (process.platform === "win32") return WIN32_HOME.map((n) => path.join(home, n))
|
|
return []
|
|
}
|
|
}
|