(filePath: string, onError?: (error: string) => void)
| 7 | |
| 8 | export namespace PlaylistFile { |
| 9 | export function readFile(filePath: string, onError?: (error: string) => void): Promise<Playlist> { |
| 10 | return new Promise((resolve, reject) => { |
| 11 | readJsonFile(filePath, 'utf8') |
| 12 | .then(json => { |
| 13 | const playlist = parse(json, onError); |
| 14 | // Remove any broken game entries |
| 15 | playlist.games = playlist.games.filter(game => !!game.gameId && game.gameId !== 'null'); // String of 'null' seems to have wormed in somehow in the past? |
| 16 | playlist.filePath = filePath; |
| 17 | resolve(playlist); |
| 18 | }) |
| 19 | .catch(reject); |
| 20 | }); |
| 21 | } |
| 22 | |
| 23 | export function readFileSync(filePath: string, onError?: (error: string) => void): Playlist { |
| 24 | const playlist = parse(readJsonFileSync(filePath), onError); |
no test coverage detected