Created
October 29, 2019 22:46
-
-
Save juliandavidmr/bf235a955228f68b6199feec6302d480 to your computer and use it in GitHub Desktop.
Generate markdown file from package-lock.json
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
// Run: node packageLock2Markdown.js "C:\..PATH..\package-lock.json" > out.md | |
const fs = require('fs'); | |
const args = process.argv.slice(2); | |
let markdownOutput = ''; | |
const contents = JSON.parse(fs.readFileSync(args[0], 'utf8')); | |
markdownOutput += `# Package: ${contents.name}`; | |
Object.keys(contents.dependencies).map(subPackageName => { | |
const content = contents.dependencies[subPackageName]; | |
const requires = content.requires; | |
const dependencies = content.dependencies; | |
markdownOutput += ` | |
## ${subPackageName} | |
**Version:** [${content.version}](${content.resolved}) | |
**Requires (${Object.keys(requires || {}).length} pks):** ${Object.keys(requires || {}).map(r => `_${r} (${requires[r]})_`).join(', ')} | |
**Dependencies (${Object.keys(dependencies || {}).length} pks):** ${Object.keys(dependencies || {}).map(r => `_${r} (${dependencies[r]})_`).join(', ')} | |
`; | |
}) | |
console.log(markdownOutput) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment