-
Notifications
You must be signed in to change notification settings - Fork 0
/
CopyAndSyncDocs.js
43 lines (37 loc) · 1.05 KB
/
CopyAndSyncDocs.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
const fs = require("fs-extra");
const copyDir = require("copy-dir");
const defaultOption = {
utimes: true,
mode: true,
cover: true,
};
const copyDirSync = (srcFolders, rootSrc, rootDest, option = {}) => {
srcFolders.forEach(folder => {
copyDir.sync(`${rootSrc}/${folder}`, `${rootDest}/${folder}`, {
...defaultOption,
...option,
});
});
};
const snapCoreFolders = [""];
fs.ensureDirSync("./docs");
copyDirSync(
snapCoreFolders,
"./examples/cra-example/storybook-static",
"./docs",
{
filter: function(stat, filepath, filename) {
// do not want copy .git directories
if (stat === "directory" && filename === "node_modules") {
return false;
}
if (stat === "directory" && filename === ".git") {
return false;
}
if (filename === "yarn.lock") {
return false;
}
return true; // remind to return a true value when file check passed.
},
}
);