Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
fix: check if files in github can be parsed. #17
Browse files Browse the repository at this point in the history
  • Loading branch information
oae committed Aug 25, 2020
1 parent 47d6630 commit 56653a9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/api/providers/github.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { SyncData } from '@esync/data';
import { logger } from '@esync/utils';
import { Context as request } from 'grest/src/app/Context/Context';
import { ApiOperationStatus, ApiProvider } from '../types';

const debug = logger('github');

export class Github implements ApiProvider {
private static GIST_API_URL = 'https://api.github.com/gists';

Expand Down Expand Up @@ -49,10 +52,15 @@ export class Github implements ApiProvider {

const syncData: SyncData = Object.keys(body.files).reduce(
(acc, key) => {
return {
...acc,
[key]: JSON.parse(body.files[key].content),
};
try {
return {
...acc,
[key]: JSON.parse(body.files[key].content),
};
} catch {
debug(`failed to parse ${key} file. skipping it...`);
return acc;
}
},
{ extensions: {}, keybindings: {}, tweaks: {} },
);
Expand Down

0 comments on commit 56653a9

Please sign in to comment.