-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (31 loc) · 1.02 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
const fs = require('fs'),
path = require('path'),
cwd = process.cwd()
let dir = __dirname,
app = dir + '/build/app',
base = dir + '/lib';
function copyFolderSync(from, to) {
try {
fs.mkdirSync(to);
} catch(e) {}
let stat;
fs.readdirSync(from).forEach(function(element){
stat = fs.lstatSync(path.join(from, element));
if (stat.isFile()) {
fs.copyFileSync(path.join(from, element), path.join(to, element));
} else if (stat.isSymbolicLink()) {
fs.symlinkSync(fs.readlinkSync(path.join(from, element)), path.join(to, element));
} else if (stat.isDirectory()) {
copyFolderSync(path.join(from, element), path.join(to, element));
}
stat = null;
});
}
function build(){
copyFolderSync(app, cwd + '/app');
copyFolderSync(base, cwd + '/app/modules');
fs.copyFileSync(dir + '/build/index.html', cwd + '/index.html');
fs.copyFileSync(dir + '/build/sw.js', cwd + '/sw.js');
fs.copyFileSync(dir + '/build/manifest.webmanifest', cwd + '/manifest.webmanifest');
}
module.exports = { build }