mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-24 17:18:09 +00:00
macOS creates metadata files named `.DS_Store`. The script incorrect tries to read it with a `.md` extension. By excluding all files that start with a dot we can prevent this.
37 lines
817 B
JavaScript
Executable File
37 lines
817 B
JavaScript
Executable File
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)
|
|
);
|