* Get candidate Terminal data directories from system.getFilesDir(). * Newer Terminal builds keep shared runtime state in public. Older builds used * alpine/home, and some installs keep it as a symlink for shell compatibility.
()
| 89 | * alpine/home, and some installs keep it as a symlink for shell compatibility. |
| 90 | */ |
| 91 | async function getTerminalDataDirs(): Promise<string[]> { |
| 92 | if (cachedFilesDir) { |
| 93 | return [`${cachedFilesDir}/public`, `${cachedFilesDir}/alpine/home`]; |
| 94 | } |
| 95 | |
| 96 | const system = ( |
| 97 | globalThis as unknown as { |
| 98 | system?: { |
| 99 | getFilesDir: ( |
| 100 | success: (filesDir: string) => void, |
| 101 | error: (error: string) => void, |
| 102 | ) => void; |
| 103 | }; |
| 104 | } |
| 105 | ).system; |
| 106 | |
| 107 | if (!system?.getFilesDir) { |
| 108 | throw new Error("System plugin is not available"); |
| 109 | } |
| 110 | |
| 111 | return new Promise((resolve, reject) => { |
| 112 | system.getFilesDir( |
| 113 | (filesDir: string) => { |
| 114 | cachedFilesDir = filesDir; |
| 115 | resolve([`${filesDir}/public`, `${filesDir}/alpine/home`]); |
| 116 | }, |
| 117 | (error: string) => reject(new Error(error)), |
| 118 | ); |
| 119 | }); |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Get the port file path for a given server and session. |
no test coverage detected