Created
February 13, 2024 09:19
-
-
Save yaf/1426907c1a38fd1fa96b249211b68c28 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
let result = 'content, file\n'; | |
const fs = require('node:fs'); | |
// Fichier `support-url-usage-in-pix.json` généré à partir de la command suivant | |
// `gh search code "support.pix" --repo 1024pix/pix --json "repository,path,textMatches,url" --jq 'map(.textMatches = (.textMatches | map(.fragment)))'` | |
const fileContent = fs.readFileSync('support-url-usage-in-pix.json', 'utf-8'); | |
const supportUrlUsage = JSON.parse(fileContent); | |
supportUrlUsage.forEach(function(usageInFile) { | |
const path = usageInFile.path; | |
const matches = usageInFile.textMatches; | |
matches.forEach(function(matchingUrl) { | |
filteredContent(matchingUrl).forEach(function(url) { | |
console.log(url) | |
result += `"${url}",${path}\n`; | |
}); | |
}); | |
}); | |
function filteredContent(matchingUrl) { | |
const splitted = matchingUrl.split('\n'); | |
const r = splitted.filter((part) => part.includes('support.pix')).join(' '); | |
let s = r.split(' ').filter((part) => part.includes('support.pix')).join(' '); | |
s = s.split('"').filter((part) => part.includes('support.pix')).join(' '); | |
s = s.split(',').filter((part) => part.includes('support.pix')).join(' '); | |
s = s.split('\'').filter((part) => part.includes('support.pix')).join(' '); | |
return s.split(' '); | |
} | |
fs.writeFile('result.csv', result, (err) => { | |
if (err) throw err; | |
console.log('The file has been saved!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment