-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.mjs
37 lines (32 loc) · 1002 Bytes
/
build.mjs
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
import { spawn } from 'child_process';
import { promises as fs } from 'fs';
import path from 'path';
async function copyFiles() {
const targetDir = '.vault/pixel-banner-example/.obsidian/plugins/pexels-banner';
const files = ['styles.css', 'main.js', 'manifest.json'];
// Ensure target directory exists
await fs.mkdir(targetDir, { recursive: true });
// Copy each file
for (const file of files) {
await fs.copyFile(file, path.join(targetDir, file));
}
}
// First run esbuild
const esbuild = spawn('node', ['esbuild.config.mjs', 'production'], {
stdio: 'inherit',
shell: true
});
esbuild.on('close', async (code) => {
if (code === 0) {
try {
await copyFiles();
console.log('Build completed successfully!');
} catch (err) {
console.error('Error copying files:', err);
process.exit(1);
}
} else {
console.error('esbuild failed');
process.exit(code);
}
});