-
Notifications
You must be signed in to change notification settings - Fork 3
/
updatedemo.js
41 lines (35 loc) · 986 Bytes
/
updatedemo.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
/* eslint-disable import/no-extraneous-dependencies */
const fs = require('fs');
const path = require('path');
const ncp = require('ncp');
function deleteFolderRecursive(directoryPath) {
if (fs.existsSync(directoryPath)) {
fs.readdirSync(directoryPath).forEach((file) => {
const curPath = path.join(directoryPath, file);
if (fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
}
else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(directoryPath);
}
}
// Delete the docs directory
deleteFolderRecursive('docs');
// Create the docs and dist directory
fs.mkdirSync('docs');
fs.mkdirSync('docs/dist');
// Copy shared demo files
ncp.ncp('demo/shared', 'docs', (err) => {
if (err) {
throw err;
}
});
// Copy dist files
ncp.ncp('dist', 'docs/dist', (err) => {
if (err) {
throw err;
}
});