Created
July 21, 2020 20:56
-
-
Save nicolasnoble/7772cea413c399fcfffa1c33eb5154be to your computer and use it in GitHub Desktop.
This file contains hidden or 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
'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