Skip to content

Commit

Permalink
misc(viewer): load *.json if no *.lighthouse.report.json (#5343)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed May 24, 2018
1 parent 996c5d7 commit 520f9ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lighthouse-viewer/app/src/github-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,13 @@ class GithubApi {

const etag = resp.headers.get('ETag');
return resp.json().then(json => {
const gistFiles = Object.keys(json.files);
// Attempt to use first file in gist with report extension.
const filename = Object.keys(json.files)
.find(filename => filename.endsWith(GithubApi.LH_JSON_EXT));
let filename = gistFiles.find(filename => filename.endsWith(GithubApi.LH_JSON_EXT));
// Otherwise, fall back to first json file in gist
if (!filename) {
filename = gistFiles.find(filename => filename.endsWith('.json'));
}
if (!filename) {
throw new Error(
`Failed to find a Lighthouse report (*${GithubApi.LH_JSON_EXT}) in gist ${id}`
Expand Down

0 comments on commit 520f9ac

Please sign in to comment.