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

Function readOrCreateFileSync

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

Source from the content-addressed store, hash-verified

35 }
36
37 export function readOrCreateFileSync(filePath: string, onError?: (error: string) => void): AppConfigData {
38 let error: Error | undefined;
39 let data: AppConfigData | undefined;
40
41 try {
42 data = readFileSync(filePath, onError);
43 } catch (e: any) {
44 error = e;
45 }
46
47 if (error || !data) {
48 data = deepCopy(getDefaultConfigData(process.platform));
49 saveFile(filePath, data).catch(() => console.log('Failed to save default config file!'));
50 }
51
52 return data;
53 }
54
55 export function saveFile(filePath: string, data: AppConfigData): Promise<void> {
56 return new Promise((resolve, reject) => {

Callers

nothing calls this directly

Calls 4

deepCopyFunction · 0.90
getDefaultConfigDataFunction · 0.90
readFileSyncFunction · 0.70
saveFileFunction · 0.70

Tested by

no test coverage detected