forked from moleculerjs/moleculer-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme-generator.js
39 lines (30 loc) · 996 Bytes
/
readme-generator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"use strict";
const path = require("path");
const glob = require("glob");
const markdownMagic = require("markdown-magic");
const readmePath = path.join(__dirname, "README.md");
console.log(readmePath);
markdownMagic(readmePath, {
transforms: {
RENDERLIST: function(content, opts) {
const folders = glob.sync(path.join(opts.folder, "*"));
//console.log(folders);
if (folders.length == 0) return " ";
let table = [
"## " + opts.title,
"| Name | Version | Description |",
"| ---- | ------- | ----------- |"
];
folders.forEach(folder => {
let name = path.basename(folder);
let pkg = require(path.resolve(folder, "package.json"));
let line = `| [${name}](/${opts.folder}/${name}#readme) | [![NPM version](https://img.shields.io/npm/v/${name}.svg)](https://www.npmjs.com/package/${name}) | ${pkg.description} |`;
table.push(line);
});
return table.join("\n");
}
},
DEBUG: false
}, () => {
console.log("README.md generated!");
});