Skip to content

Instantly share code, notes, and snippets.

@nicolasnoble
Created July 21, 2020 20:56
Show Gist options
  • Save nicolasnoble/7772cea413c399fcfffa1c33eb5154be to your computer and use it in GitHub Desktop.
Save nicolasnoble/7772cea413c399fcfffa1c33eb5154be to your computer and use it in GitHub Desktop.
'use strict'
const {promisify} = require('util')
const download = promisify(require('download-git-repo'))
const fs = require('fs')
const glob = promisify(require('glob'))
const yaml = require('js-yaml')
const data = []
download('microsoft/winget-pkgs', 'temp')
.then(() => glob('temp/**/*.yaml'))
.then(paths => Promise.all(paths.map(path => fs.promises.readFile(path))))
.then(files => {
files.forEach(file => {
try {
const doc = yaml.safeLoad(file)
data.push({id: doc.Id, description: doc.Description })
}
catch (e) { console.log("failed parsing one file") }
})
console.log(data)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment