-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathembed-build.js
More file actions
30 lines (28 loc) · 916 Bytes
/
embed-build.js
File metadata and controls
30 lines (28 loc) · 916 Bytes
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
const path = require("path");
const fs = require("fs/promises");
const main = async () => {
try {
const absolutePath = path.resolve("", "");
const frontPath = path.resolve("../", "react-upbond-embed/embed")
try {
await fs.access(frontPath);
console.log(`The folder '${frontPath}' exists. Deleting it...`);
await fs.rm(frontPath, { recursive: true });
console.log("Folder deleted.");
} catch (error) {
console.log(`The folder '${frontPath}' does not exist.`, error);
}
const readDist = await fs.readdir(`${absolutePath}`);
for (let i in readDist) {
if (readDist[i] === "dist") {
// put your dist path here ...
const distPath = `${absolutePath}/${readDist[i]}`;
await fs.rename(distPath, frontPath);
}
}
console.log(frontPath);
} catch (error) {
throw new Error(error);
}
};
main().catch(console.error);