-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
74 lines (61 loc) · 2.42 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// import fs from 'fs';
// import path from 'path';
// import { fileURLToPath } from 'url';
// import { defineConfig } from 'vite';
// const __filename = fileURLToPath(import.meta.url);
// const __dirname = path.dirname(__filename);
// // Function to copy files
// function copyFiles(src, dest) {
// const srcDir = path.join(__dirname, src);
// const destDir = path.join(__dirname, dest);
// // Create destination directory if it doesn't exist
// if (!fs.existsSync(dest)) {
// fs.mkdirSync(dest, { recursive: true });
// }
// const files = fs.readdirSync(src);
// for (const file of files) {
// const srcFile = path.join(srcDir, file);
// const destFile = path.join(destDir, file);
// fs.copyFileSync(srcFile, destFile);
// console.log(`Copied ${srcFile} to ${destFile}`);
// }
// }
// function printDirectoryContentsAsync(directoryPath) {
// fs.readdir(directoryPath, (err, files) => {
// if (err) {
// console.error(`Error reading directory: ${err.message}`);
// return;
// }
// console.log(`Contents of ${directoryPath}:`);
// files.forEach(file => {
// console.log(file);
// });
// });
// }
// async function getBuildPath() {
// // Import the Vite configuration
// const viteConfig = await import('./vite.config.js');
// // Resolve the configuration (execute the function if it's a function)
// const resolvedConfig = (typeof viteConfig === 'function') ? defineConfig(viteConfig()) : defineConfig(viteConfig);
// // Retrieve the build output directory
// const outDir = resolvedConfig.build?.outDir || '.svelte-kit/output/server/entries';
// console.log(
// 'base is: ', process.cwd(), '\n',
// 'resolvedConfig: ', resolvedConfig, '\n',
// 'resolvedConfig.build: ', resolvedConfig.build, '\n',
// 'resolvedConfig.build.outDir: ', resolvedConfig.build ? resolvedConfig.build.outDir : undefined, '\n',
// 'outDir: ', outDir, '\n',
// );
// // Return the relative path
// return outDir;
// // return path.resolve(process.cwd(), outDir);
// }
// async function main() {
// const buildPath = await getBuildPath();
// // copy markdown tree files
// copyFiles('trees', path.join(buildPath, 'trees'));
// console.log('buildPath: ', buildPath);
// console.log(printDirectoryContentsAsync(path.join(__dirname, buildPath)));
// // copyFiles('trees', path.join('.netlify', 'trees'));
// }
// main().catch((err) => console.error(err));