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

Function readFile

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

Source from the content-addressed store, hash-verified

7
8export 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);

Callers 1

readOrCreateFileFunction · 0.70

Calls 2

readJsonFileFunction · 0.90
parseFunction · 0.70

Tested by

no test coverage detected