Implemented recursive calls and markdown export

This commit is contained in:
Nicolai Ort 2020-12-31 16:15:36 +01:00
parent 8103febbb6
commit d0e84f7391

View File

@ -46,9 +46,20 @@ function getDependencyLicenseInfo(all_dependencies, recursive){
const packageInfo = parsePackageInfo(`./package.json`);
const all = getDependencyLicenseInfo(mergeDependencies(packageInfo), args.includes("--recursive"));
if (args.includes("--json")) {
if (args.includes("--pretty")) {
fs.writeFileSync('./licenses.json', JSON.stringify(all, null, 4));
}
else {
fs.writeFileSync('./licenses.json', JSON.stringify(all));
}
}
if (args.includes("--md")) {
fs.writeFileSync('./licenses.md', "");
all.forEach((p) => {
fs.appendFileSync("./licenses.md", `# ${p.name}\n**Author**: ${p.author}\n**Repo**: ${p.repo}\n**License**: ${p.license}\n**Description**: ${p.description}\n## License Text\n${p.licensetext} \n\n`)
});
}
else {
return all;
}