-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.js
More file actions
42 lines (34 loc) · 1.03 KB
/
build.js
File metadata and controls
42 lines (34 loc) · 1.03 KB
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
import { build as esbuild } from 'esbuild'
import { readdirSync, statSync, copyFileSync, mkdirSync } from 'fs'
import { join } from 'path'
async function copyRecursive(src, dest) {
const stat = statSync(src)
if (stat.isDirectory()) {
mkdirSync(dest, { recursive: true })
const files = readdirSync(src)
for (const file of files) {
copyRecursive(join(src, file), join(dest, file))
}
} else {
copyFileSync(src, dest)
}
}
async function build() {
console.log('Building...')
await esbuild({
entryPoints: ['notificator.js'],
bundle: true,
outfile: 'dist/notificator.js',
platform: 'node',
target: 'node18',
format: 'esm',
external: ['@opencode-ai/plugin'],
sourcemap: true,
})
console.log('Copying sounds...')
copyRecursive('notificator-sounds', 'dist/notificator-sounds')
console.log('Copying config...')
copyFileSync('notificator.jsonc', 'dist/notificator.jsonc')
console.log('Build complete! Copy dist/ to your OpenCode plugins directory.')
}
build().catch(console.error)