-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
42 lines (35 loc) · 1.03 KB
/
build.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
const fs = require("fs");
const archiver = require("archiver");
const modules = fs.readdirSync("node_modules");
const output = fs.createWriteStream("package-archive.zip");
const archive = archiver("zip", { zlib: { level: 9 } });
const subfolder = "my-project-files";
if (!fs.existsSync(subfolder)) {
fs.mkdirSync(subfolder);
}
const excludedFiles = [
subfolder,
"components",
"archive.js",
"build.js",
".github",
".git",
];
// Get all files and directories in the current folder
const files = fs.readdirSync(".");
for (const file of files) {
// Exclude the excluded files/directories
if (!excludedFiles.includes(file)) {
fs.renameSync(file, `${subfolder}/${file}`);
}
}
//Copy components dist folder
fs.mkdirSync(`${subfolder}/components`);
fs.renameSync("components/dist", `${subfolder}/components/dist`);
output.on("close", () => {
console.log("Archive created successfully.");
});
archive.pipe(output);
archive.directory(subfolder, false);
archive.finalize();
console.log("Dependencies removed and archive created.");