Skip to content

Commit

Permalink
Refactor getWebsiteStack function to use async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
maxontech committed Mar 14, 2024
1 parent ea6bc21 commit 6d88574
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions docs/parse-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ const getMetaDescription = async (page) => {
}


const getWebsiteStack = await page.evaluate(() => {

const getWebsiteStack = async (page) => {
return page.evaluate(() => {
if (!!window.React ||
!!document.querySelector('[data-reactroot], [data-reactid]') ||
Array.from(document.querySelectorAll('*')).some(e => e._reactRootContainer !== undefined || Object.keys(e).some(k => k.startsWith('__reactContainer')))
)
return 'React';

if(!!window.jQuery)
return 'jQuery';

if (!!document.querySelector('script[id=__NEXT_DATA__]'))
return 'Next.js';

Expand Down Expand Up @@ -76,7 +79,8 @@ const getWebsiteStack = await page.evaluate(() => {

if(!!window.Nuxt || !!window.__NUXT__)
return 'Nuxt.js';
});
});
}

//fs.readFile(filePath, 'utf8', async function (err, data) {
const processFile = async (filePath) => {
Expand Down Expand Up @@ -110,15 +114,15 @@ const processFile = async (filePath) => {
companyName,
screenshotPath: `screenshots/${companyName.replace(/\s/g, '')}.jpeg`,
tags,
stack: [],
stack: websiteStack,
timeToPageLoad
};
console.log(dataObject);
dataObjects.push(dataObject);
}

const json = JSON.stringify(dataObjects, null, 2);
console.log(json);
//const json = JSON.stringify(dataObjects, null, 2);
//console.log(json);
}

processFile(filePath);
Expand Down

0 comments on commit 6d88574

Please sign in to comment.