-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ts
More file actions
50 lines (39 loc) · 1.27 KB
/
build.ts
File metadata and controls
50 lines (39 loc) · 1.27 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
43
44
45
46
47
48
49
50
import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
const result = await Bun.build({
entrypoints: ['./src/extension.ts'],
outdir: './dist',
target: 'node',
external: ['vscode'],
minify: false,
sourcemap: 'external'
});
if (!result.success) {
console.error('Build failed:', result.logs);
process.exit(1);
}
if (!existsSync('./dist')) {
mkdirSync('./dist', { recursive: true });
}
if (existsSync('./package.json')) {
const packageJson = JSON.parse(readFileSync('./package.json', 'utf-8'));
packageJson.main = './extension.js';
delete packageJson.scripts;
delete packageJson.devDependencies;
writeFileSync('./dist/package.json', JSON.stringify(packageJson, null, 2));
console.log('Copied and modified package.json to dist/');
} else {
console.log('[X] package.json not found!');
process.exit(1);
}
const otherFiles = ['README.md', 'LICENSE'];
for (const file of otherFiles) {
const srcPath = `./${file}`;
const destPath = `./dist/${file}`;
if (existsSync(srcPath)) {
copyFileSync(srcPath, destPath);
console.log(`Copied ${file} to dist/`);
} else {
console.log(`${file} not found, skipping...`);
}
}
console.log('Build completed successfully!');