-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
43 lines (37 loc) · 934 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
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict";
let args = require('minimist');
let path = require('path');
let _ = require('lodash');
let as = require('async');
let helpers = require('./lib/helpers.js');
let content = require('./lib/content.js');
let server = require('./lib/server.js');
let build = require('./lib/build.js');
module.exports = (opts, cb) => {
opts = args(opts, {
'alias': {
'p': 'port',
's': 'source',
'c': 'cache'
},
'default': {
// Example site.
's': './example/',
// Max cache age of 1 day.
'c': 60 * 24
}
});
opts.source = path.resolve(opts.source);
// Callback?
if (!_.isFunction(cb)) cb = _.identity;
as.waterfall([
// Require helper menthods.
_.partial(helpers, opts),
// Load all content.
_.partial(content, opts),
// Build all pages to check for errors.
_.partial(build, opts),
// Start server.
_.partial(server, opts),
], cb);
};