1 | const fs = require('fs-extra')
|
2 | const globby = require('globby')
|
3 | const processFile = require('./lib/processFile')
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | module.exports = function markdownMagic(filePaths, config, callback) {
|
18 | const files = globby.sync(filePaths)
|
19 | const configuration = config || {}
|
20 | if (!callback && typeof configuration === 'function') {
|
21 | callback = configuration
|
22 | } else if (typeof config === 'object' && config.callback) {
|
23 |
|
24 | callback = config.callback
|
25 | }
|
26 | if (!files.length) {
|
27 | callback && callback('No files matched')
|
28 | console.log('No files matched pattern', filePaths)
|
29 | return false
|
30 | }
|
31 | configuration.originalFilePaths = files
|
32 | const data = []
|
33 | files.forEach((file) => {
|
34 | const output = processFile(file, configuration)
|
35 | data.push(output)
|
36 | })
|
37 | if (callback) {
|
38 | callback(null, data)
|
39 | }
|
40 | }
|
41 |
|
42 |
|
43 | module.exports.globby = globby
|
44 |
|
45 |
|
46 | module.exports.fsExtra = fs
|