-
Notifications
You must be signed in to change notification settings - Fork 9
/
run.js
26 lines (18 loc) · 847 Bytes
/
run.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
const fsExtra = require('fs-extra')
const { transform, generateTransformInput } = require('./build')
const path = require('path')
console.log('process.env.mortyPath = ', process.env.mortyPath)
const directoryToConvert = process.env.mortyPath || 'default-md-files'
const resolvedPath = path.resolve(directoryToConvert)
const mortyDocs = async () => {
const basePath = 'morty-docs/some-repo'
const inputObjs = await generateTransformInput(resolvedPath)
const files = transform(inputObjs, { contentTitle: 'some-repo', basePath })
files.forEach(file => {
let filePath = `www/${basePath}/${file.relativePath}`
fsExtra.ensureFileSync(filePath)
fsExtra.writeFileSync(filePath, file.raw)
})
return 'Creating html files in www directory'
}
mortyDocs().then(data => console.log(data)).catch(err => console.log('error', err))