-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (42 loc) · 1.31 KB
/
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
44
45
46
47
48
49
50
const fs = require('fs')
const path = require('path')
const HtmlPagesGenerator = require('./html-pages-generator')
module.exports = class Fkit {
constructor(options) {
this.options = options;
this.env = options.env;
this.path = options.path;
this.config = this.pathConfig();
this.initApp();
}
pathConfig() {
const mainPath = this.options.path;
return {
path: mainPath,
srcPath: path.resolve(mainPath, 'src'),
publicPath: path.resolve(mainPath, 'public'),
pagesPath: path.resolve(mainPath, 'src/pages'),
layoutsPath: path.resolve(mainPath, 'src/layouts'),
}
}
apply(compiler) {
new HtmlPagesGenerator(this.config, this.env).compiler(compiler);
}
initApp() {
const pagesPath = this.config.pagesPath;
const publicPath = this.config.publicPath;
const layoutsPath = this.config.layoutsPath;
// Check pages path
if (!fs.existsSync(pagesPath)) {
fs.mkdirSync(pagesPath);
}
// Check layouts path
if (!fs.existsSync(layoutsPath)) {
fs.mkdirSync(layoutsPath);
}
// Check public path
if (!fs.existsSync(publicPath)) {
fs.mkdirSync(publicPath);
}
}
}