Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function generateReport(site, data, type) {
let promise = new Promise((resolve, reject) => {
launchChromeAndRunLighthouse(v.url, {output: type})
.then((data) => {
data = JSON.stringify(data);
// timestamep will be used on the filename
let timeStamp = DateTime.local().toISODate();
// Directory may not exist yet
if (!fs.existsSync(`reports/${v.name}`)) {
fs.mkdirSync(`reports/${v.name}`);
}
// Directory may not exist yet
if (!fs.existsSync(`reports/${v.name}/${type}`)) {
fs.mkdirSync(`reports/${v.name}/${type}`);
}
fs.writeFile(`reports/${v.name}/${v.name}-${timeStamp}.${type}`, data);
})
.catch(handleError);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.