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

Function saveFile

src/back/PlaylistFile.ts:65–79  ·  view source on GitHub ↗
(filePath: string, data: Playlist)

Source from the content-addressed store, hash-verified

63 }
64
65 export function saveFile(filePath: string, data: Playlist): Promise<void> {
66 const playlistToSave = {
67 ...data,
68 filePath: undefined
69 };
70 return new Promise((resolve, reject) => {
71 // Convert config to json string
72 const json: string = stringifyJsonDataFile(playlistToSave);
73 // Save the config file
74 fs.writeFile(filePath, json, function(error) {
75 if (error) { return reject(error); }
76 else { return resolve(); }
77 });
78 });
79 }
80
81 function parse(json: any, onError?: (error: string) => void): Playlist {
82 return overwritePlaylistData(deepCopy(DEFAULT_PLAYLIST_DATA), json, onError);

Callers 2

readOrCreateFileFunction · 0.70
readOrCreateFileSyncFunction · 0.70

Calls 1

stringifyJsonDataFileFunction · 0.90

Tested by

no test coverage detected