Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ Below are options for the exported `lighthouseCheck` function or `lighthouse-che
<tr>
<td><code>emulatedFormFactor</code></td>
<td>Lighthouse setting only used for local audits. See <a href="src/lighthouseConfig.js">src/lighthouseConfig.js</a> comments for details.</td>
<td><code>oneOf(['mobile', 'desktop']</code></td>
<td><code>oneOf(['mobile', 'desktop','both'])</code></td>
<td><code>local</code></td>
<td><code>undefined</code></td>
<td>no</td>
Expand Down
2 changes: 1 addition & 1 deletion src/lighthouseCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default ({
awsBucket,
awsRegion,
awsSecretAccessKey,
emulatedFormFactor,
emulatedFormFactor = 'mobile',
extraHeaders,
branch,
isGitHubAction,
Expand Down
42 changes: 33 additions & 9 deletions src/localLighthouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const localLighthouse = async ({
url,
localReport,
report,
emulatedFormFactor,
scores
};
};
Expand Down Expand Up @@ -143,11 +144,7 @@ export default async ({
let index = 1;

for (const url of urls) {
if (verbose) {
console.log(`${NAME}: Auditing (${index}/${urls.length}) ${url}`);
}

const lighthouseAuditResult = await localLighthouse({
const options = {
awsAccessKeyId,
awsBucket,
awsRegion,
Expand All @@ -160,11 +157,38 @@ export default async ({
overrides,
throttling,
throttlingMethod,
url
});
url,
verbose
};

auditResults.push(lighthouseAuditResult);
index++;
if (options.emulatedFormFactor !== 'both') {
if (verbose) {
Copy link
Collaborator

@adamhenson adamhenson Jun 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I wasn't clear @Mirzamohammad22. My point is that we don't need to have this block repeated now. We can leave it where it was.

EDITED: My mistake, I see why we need it, because options is changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues , let me know if the If case is fine or should i revert to lighthouseCaller

console.log(
`${NAME}: Auditing (${index}/${urls.length}) ${options.url} in Mode:${options.emulatedFormFactor}`
);
}
const lighthouseAuditResult = await localLighthouse(options);
auditResults.push(lighthouseAuditResult);
index++;
} else {
options.emulatedFormFactor = 'desktop';
if (verbose) {
console.log(
`${NAME}: Auditing (${index}/${urls.length}) ${options.url} in Mode:${options.emulatedFormFactor}`
);
}
const lighthouseAuditResultDesktop = await localLighthouse(options);
options.emulatedFormFactor = 'mobile';
if (verbose) {
console.log(
`${NAME}: Auditing (${index}/${urls.length}) ${options.url} in Mode:${options.emulatedFormFactor}`
);
}
const lighthouseAuditResultMobile = await localLighthouse(options);
auditResults.push(lighthouseAuditResultDesktop);
auditResults.push(lighthouseAuditResultMobile);
index++;
}
}

// if outputDirectory is specified write the results to disk
Expand Down
5 changes: 4 additions & 1 deletion src/postPrComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default async ({
});
});

// the emulatedformfactor
markdown += `\n\n Mode: **${result.emulatedFormFactor}**`;

// the url
markdown += `\n\n${result.url}`;

Expand All @@ -48,7 +51,7 @@ export default async ({

// create an identifier within the comment when searching comments
// in the future
const commentIdentifier = '<!-- generated by lighthouse-check -->';
const commentIdentifier = '\n<!-- generated by lighthouse-check -->';
markdown += commentIdentifier;

// establish existing comment
Expand Down