MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / syncWorkspaceTextFile

Function syncWorkspaceTextFile

apps/desktop/src/main/ipc/runtime-fs.ts:222–244  ·  view source on GitHub ↗
(
    filePath: string,
    absolutePath?: string,
  )

Source from the content-addressed store, hash-verified

220 }
221
222 async function syncWorkspaceTextFile(
223 filePath: string,
224 absolutePath?: string,
225 ): Promise<{ path: string; content: string }> {
226 const normalizedPath = normalizeDesignFilePath(filePath);
227 assertWorkspacePathVisible(normalizedPath);
228 const sourcePath = absolutePath;
229 let content: string;
230 if (!sourcePath) {
231 if (designId === null || db === null) {
232 throw new Error(`Workspace path unavailable for ${normalizedPath}`);
233 }
234 content = await withResolvedWorkspace(normalizedPath, async (_workspacePath, path) =>
235 readFile(path, 'utf8'),
236 );
237 } else {
238 content = await readFile(sourcePath, 'utf8');
239 }
240 fsMap.set(normalizedPath, content);
241 emitFsUpdated(normalizedPath, content);
242 emitSourceIfAssetChanged(normalizedPath);
243 return { path: normalizedPath, content };
244 }
245
246 const fs = {
247 view(path: string) {

Callers 2

runGenerateFunction · 0.85

Calls 5

normalizeDesignFilePathFunction · 0.90
withResolvedWorkspaceFunction · 0.85
emitFsUpdatedFunction · 0.85
emitSourceIfAssetChangedFunction · 0.85

Tested by

no test coverage detected