(filePath: string, data: Playlist)
| 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); |
no test coverage detected