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