MCPcopy
hub / github.com/foambubble/foam / writeFile

Method writeFile

packages/foam-vscode/src/test/vscode-mock.ts:1254–1271  ·  view source on GitHub ↗
(uri: Uri, content: Uint8Array)

Source from the content-addressed store, hash-verified

1252 }
1253
1254 async writeFile(uri: Uri, content: Uint8Array): Promise<void> {
1255 // Check if file exists before writing
1256 const existed = await this.exists(uri);
1257
1258 // Ensure directory exists
1259 const dir = path.dirname(uri.fsPath);
1260 await fs.promises.mkdir(dir, { recursive: true });
1261 await fs.promises.writeFile(uri.fsPath, content);
1262
1263 // Fire watcher events
1264 for (const watcher of mockState.fileWatchers) {
1265 if (existed) {
1266 watcher._fireChange(uri);
1267 } else {
1268 watcher._fireCreate(uri);
1269 }
1270 }
1271 }
1272
1273 private async exists(uri: Uri): Promise<boolean> {
1274 try {

Callers

nothing calls this directly

Calls 4

existsMethod · 0.95
_fireChangeMethod · 0.80
_fireCreateMethod · 0.80
writeFileMethod · 0.65

Tested by

no test coverage detected