forked from react-navigation/react-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile-docs.js
More file actions
executable file
·36 lines (31 loc) · 817 Bytes
/
Copy pathcompile-docs.js
File metadata and controls
executable file
·36 lines (31 loc) · 817 Bytes
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
const path = require('path');
var fs = require('fs');
var join = require('path').join;
var files = [];
function crawl(location) {
var dir = fs.readdirSync(location);
dir.map(function(name, index) {
var stat = fs.statSync(join(location, name));
if (stat.isDirectory()) {
crawl(join(location, name));
} else if (name[0] !== '.') {
files.push(join(location, name));
}
});
}
crawl('docs');
var names = files.map(function(file) {
const nameWithExt = file.split('docs' + path.sep)[1];
const name = nameWithExt.split('.md')[0];
return name;
});
var mdData = {};
names.map(function(name) {
mdData[name] = fs.readFileSync('docs' + path.sep + name + '.md', {
encoding: 'utf8',
});
});
fs.writeFileSync(
'website' + path.sep + 'docs-dist.json',
JSON.stringify(mdData)
);