MCPcopy
hub / github.com/claude-code-best/claude-code / writeToDisk

Function writeToDisk

src/utils/plugins/pluginFlagging.ts:86–110  ·  view source on GitHub ↗
(
  plugins: Record<string, FlaggedPlugin>,
)

Source from the content-addressed store, hash-verified

84}
85
86async 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.

Callers 4

loadFlaggedPluginsFunction · 0.85
addFlaggedPluginFunction · 0.85
markFlaggedPluginsSeenFunction · 0.85
removeFlaggedPluginFunction · 0.85

Calls 8

getFlaggedPluginsPathFunction · 0.85
getFsImplementationFunction · 0.85
getPluginsDirectoryFunction · 0.85
jsonStringifyFunction · 0.85
renameFunction · 0.85
unlinkFunction · 0.85
toStringMethod · 0.65
logErrorFunction · 0.50

Tested by

no test coverage detected