-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
30 lines (28 loc) · 810 Bytes
/
index.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
27
28
29
30
const ncp = require('ncp');
const stream = require('unified-stream');
const { renderSass, renameFiles, makeProcessor } = require('./controllers');
require('dotenv').config();
// Global process variables
const out_dir = process.env.build_directory || 'out';
const in_dir = process.env.inbound_md_directory || 'content';
const renderHtml = () => {
return new Promise((resolve, reject) => {
const filePaths = [];
ncp(in_dir, out_dir, {
transform: (read, write, file) => {
filePaths.push(file.name);
read
.pipe(stream(makeProcessor(file.name)))
.pipe(write)
}
}, function (err) {
if (err) { reject(err); }
resolve(filePaths);
})
})
}
renderHtml().then((filePaths) => {
renderSass().then(() => {
renameFiles(filePaths);
})
})