Skip to content

Commit

Permalink
Merge pull request #94 from pwa-builder/dev
Browse files Browse the repository at this point in the history
Fix webAppReport output
  • Loading branch information
khmyznikov authored Nov 27, 2023
2 parents 9d4ab80 + a3e059d commit d6c3c74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
32 changes: 22 additions & 10 deletions Report/lighthouse/lighthouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,27 @@ const audit = async (page: any, url: string, desktop?: boolean) => {
};
}
catch (error) {
if (process.stdout)
process.stdout.write(JSON.stringify(error, Object.getOwnPropertyNames(error)));
process.exit(1);
writeAndExit(error, 1);
}
};

const writeAndExit = (data: any, code: 1 | 0) => {
if (process.stdout) {
if (code){
process.stdout.write(JSON.stringify(data, Object.getOwnPropertyNames(data)), () => {
process.exit(code)
});
}
else {
process.stdout.write(JSON.stringify(data), () => {
process.exit(code);
});
}
}
else
process.exit(code);
}

// adding puppeter's like flags https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/node/ChromeLauncher.ts
// on to op chrome-launcher https://github.com/GoogleChrome/chrome-launcher/blob/main/src/flags.ts#L13

Expand Down Expand Up @@ -170,20 +185,17 @@ async function execute() {
error: 'Service worker timed out',
};
}
if (manifest_alt.url && manifest_alt.raw && (!webAppReport?.artifacts?.Manifest?.raw || manifest_alt.raw > webAppReport.artifacts.Manifest.raw)) {
if (manifest_alt.url && webAppReport && manifest_alt.raw && (!webAppReport?.artifacts?.Manifest?.raw || manifest_alt.raw > webAppReport.artifacts.Manifest.raw)) {
webAppReport.artifacts.Manifest = manifest_alt;
}

await currentBrowser.close();

process.stdout && process.stdout.write(JSON.stringify(webAppReport));
process.exit(0);

writeAndExit(webAppReport, 0);
} catch (error: any) {
await currentBrowser.close();

process.stdout && process.stdout.write(JSON.stringify(error, Object.getOwnPropertyNames(error)));
process.exit(1);

writeAndExit(error, 1);
}
};

Expand Down
1 change: 0 additions & 1 deletion tests/test_urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"https://nute.app/",
"https://garfieldapp.tk/",
"https://microsoftedge.github.io/Demos/wami/",
"https://www.match.cards/",
"https://app.mapbuddy.app/",
"https://breedershub.in",
"https://ril.kryptografische.biz/",
Expand Down

0 comments on commit d6c3c74

Please sign in to comment.