MCPcopy Create free account
hub / github.com/FlashpointProject/launcher / readOrCreateFileSync

Function readOrCreateFileSync

src/back/PlaylistFile.ts:47–63  ·  view source on GitHub ↗
(filePath: string, onError?: (error: string) => void)

Source from the content-addressed store, hash-verified

45 }
46
47 export function readOrCreateFileSync(filePath: string, onError?: (error: string) => void): Playlist {
48 let error: Error | undefined;
49 let data: Playlist | undefined;
50
51 try {
52 data = readFileSync(filePath, onError);
53 } catch (e: any) {
54 error = e;
55 }
56
57 if (error || !data) {
58 data = deepCopy(DEFAULT_PLAYLIST_DATA);
59 saveFile(filePath, data).catch(() => console.log('Failed to save default config file!'));
60 }
61
62 return data;
63 }
64
65 export function saveFile(filePath: string, data: Playlist): Promise<void> {
66 const playlistToSave = {

Callers

nothing calls this directly

Calls 3

deepCopyFunction · 0.90
readFileSyncFunction · 0.70
saveFileFunction · 0.70

Tested by

no test coverage detected