This repository was archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare-build.ts
More file actions
54 lines (45 loc) · 1.61 KB
/
prepare-build.ts
File metadata and controls
54 lines (45 loc) · 1.61 KB
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
51
52
53
54
var fs = require('fs');
var path = require('path');
function copyFileSync(source:String, target:String) {
var targetFile = target;
//If target is a directory, a new file with the same name will be created
if (fs.existsSync(target)) {
if (fs.lstatSync(target).isDirectory()) {
targetFile = path.join( target, path.basename(source));
}
}
fs.writeFileSync(targetFile, fs.readFileSync(source));
}
function copyFolderRecursiveSync(source:String, target:String) {
var files = [];
//Make sure the target folder it self exists
if (!fs.existsSync(target)) {
fs.mkdirSync(target);
}
//Check if folder needs to be created or integrated
var targetFolder = path.join(target, path.basename(source));
if (!fs.existsSync(targetFolder)) {
fs.mkdirSync(targetFolder);
}
//Copy
if (fs.lstatSync(source).isDirectory()) {
files = fs.readdirSync(source);
files.forEach(function(file) {
var curSource = path.join(source, file);
if (fs.lstatSync(curSource).isDirectory()) {
copyFolderRecursiveSync(curSource, targetFolder);
}
else {
copyFileSync(curSource, targetFolder);
}
});
}
}
copyFolderRecursiveSync("dist/", "build/");
copyFolderRecursiveSync("ContentTemplate/", "build/");
copyFolderRecursiveSync("_includes/", "build/");
copyFileSync("template.yml", "build/")
copyFileSync("LICENSE", "build/")
copyFileSync("Conceptual.html.liquid", "build/")
copyFileSync("Home.html.liquid", "build/")
copyFileSync("Reference.html.liquid", "build/")