fix(hooks): fix parsing a manifest that doesn't exist

This commit is contained in:
Jonathan Rainville 2019-05-03 12:58:42 -04:00
parent 8c4413c644
commit 3fd72ff15f
No known key found for this signature in database
GPG Key ID: 5F4630B759727D9C

View File

@ -82,7 +82,20 @@ export function useProfileData(profiles) {
}
const getProjectManifest = assets => {
return assets ? JSON.parse(assets.find(a => a.name.toLowerCase() === 'manifest.json').content) : null
if (!assets) {
return null;
}
const manifest = assets.find(a => a.name.toLowerCase() === 'manifest.json');
if (!manifest) {
return null;
}
try {
return JSON.parse(manifest.content)
} catch (e) {
console.error('Wtf', manifest);
return null;
}
}
export function useProjectData(projectId, profile, projectAddedEvents) {