( plugins: Record<string, FlaggedPlugin>, )
| 86 | } |
| 87 | |
| 88 | async function writeToDisk( |
| 89 | plugins: Record<string, FlaggedPlugin>, |
| 90 | ): Promise<void> { |
| 91 | const filePath = getFlaggedPluginsPath() |
| 92 | const tempPath = `${filePath}.${randomBytes(8).toString('hex')}.tmp` |
| 93 | |
| 94 | try { |
| 95 | await getFsImplementation().mkdir(getPluginsDirectory()) |
| 96 | |
| 97 | const content = jsonStringify({ plugins }, null, 2) |
| 98 | await writeFile(tempPath, content, { |
| 99 | encoding: 'utf-8', |
| 100 | mode: 0o600, |
| 101 | }) |
| 102 | await rename(tempPath, filePath) |
| 103 | cache = plugins |
| 104 | } catch (error) { |
| 105 | logError(error) |
| 106 | try { |
| 107 | await unlink(tempPath) |
| 108 | } catch { |
| 109 | // Ignore cleanup errors |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Load flagged plugins from disk into the module cache. |
no test coverage detected