-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocParse.js
More file actions
27 lines (23 loc) · 778 Bytes
/
docParse.js
File metadata and controls
27 lines (23 loc) · 778 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
const { writeFileSync } = require('fs');
const { sep } = require('path');
const mkdirSync = require('fs-mkdirp-sync');
const readdir = require('readdir-sync-recursive');
const parseFile = require('./utils/parseFile');
const normalizeEntry = require('./utils/normalizeEntry');
const parseFileWithOutput = output => {
return file => {
parseFile(file, output);
};
};
const docParse = ({ entry, output }) => {
const rawDirPath = output.split(sep);
rawDirPath.pop();
const dirPath = rawDirPath.join(sep);
mkdirSync(dirPath);
writeFileSync(output, '');
const entryPoints = normalizeEntry(entry);
for (let i = 0, length = entryPoints.length; i < length; i++) {
readdir(entryPoints[i], null, parseFileWithOutput(output));
}
};
module.exports = docParse;