-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro_path.js
31 lines (25 loc) · 894 Bytes
/
astro_path.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
import fs from 'fs';
import path from 'path';
// Paths
const source = path.join('dist', '_astro');
const destination = path.join('dist', 'ntw2029', '_astro');
// Ensure the destination directory exists
fs.mkdirSync(destination, { recursive: true });
// Copy files from source to destination
function copyFolderSync(from, to) {
fs.readdirSync(from).forEach(element => {
const fromPath = path.join(from, element);
const toPath = path.join(to, element);
if (fs.lstatSync(fromPath).isFile()) {
fs.copyFileSync(fromPath, toPath);
} else {
fs.mkdirSync(toPath, { recursive: true });
copyFolderSync(fromPath, toPath);
}
});
}
// Copy the contents of the _astro folder
copyFolderSync(source, destination);
// Remove the original _astro folder after copying
fs.rmSync(source, { recursive: true, force: true });
console.log('Build create successfully!.');