Created
November 30, 2017 13:36
-
-
Save jasonwilliams/aa32fafda054a2f889716d3811fffea9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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