-
Notifications
You must be signed in to change notification settings - Fork 4
/
updateREADME.js
38 lines (32 loc) · 1.08 KB
/
updateREADME.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
const path = require('path')
const markdownMagic = require('markdown-magic')
const init = require('sync-rpc')
const getReposSync = init(require.resolve('./scripts/getRepos.js'))
function generateRepoLinkMarkdown( repos ){
let yamlOutput = ''
repos.forEach( (val) =>{
const description = val.description ? ` - ${val.description}` : ''
yamlOutput += `- [${val.name}](${val.html_url})${description}\n`
})
return yamlOutput
}
function getRepoLinkMarkdown( username ) {
const repos = getReposSync( username )
if( ! repos || ! Object.keys(repos).length ){
return content
}
return generateRepoLinkMarkdown( repos )
}
const config = {
transforms: {
// CONTRIBUTORS: require('markdown-magic-github-contributors'),
OFFICIAL_APPS: ( content, options ) => {
return getRepoLinkMarkdown( 'mongoose-os-apps' )
},
OFFICIAL_LIBS: ( content, options ) => {
return getRepoLinkMarkdown( 'mongoose-os-libs' )
}
},
}
const markdownPath = path.join(__dirname, 'README.md')
markdownMagic(markdownPath, config)