|
1 | 1 | #!/usr/bin/env node |
2 | 2 |
|
3 | | -import { spawn } from 'node:child_process'; |
| 3 | +import { execSync } from 'node:child_process'; |
4 | 4 | import { existsSync, statSync } from 'node:fs'; |
5 | 5 | import { dirname, resolve } from 'node:path'; |
6 | 6 | import { fileURLToPath } from 'node:url'; |
@@ -33,49 +33,28 @@ function checkBundlerBuilt(): boolean { |
33 | 33 | async function buildBundler(): Promise<void> { |
34 | 34 | console.log('🔨 Building bundler...'); |
35 | 35 |
|
36 | | - return new Promise((resolve, reject) => { |
37 | | - const isWindows = process.platform === 'win32'; |
38 | | - const cmd = isWindows ? 'cmd.exe' : 'pnpm'; |
39 | | - const args = isWindows ? ['/c', 'pnpm', 'build'] : ['build']; |
40 | | - const child = spawn(cmd, args, { |
| 36 | + try { |
| 37 | + execSync('pnpm build', { |
41 | 38 | cwd: BUNDLER_PATH, |
42 | 39 | stdio: 'inherit', |
43 | | - shell: false, |
44 | | - }); |
45 | | - |
46 | | - child.on('close', (code) => { |
47 | | - if (code === 0) { |
48 | | - console.log('✅ Bundler built successfully'); |
49 | | - resolve(); |
50 | | - } else { |
51 | | - reject(new Error(`Bundler build failed with code ${code}`)); |
52 | | - } |
53 | 40 | }); |
54 | | - |
55 | | - child.on('error', reject); |
56 | | - }); |
| 41 | + console.log('✅ Bundler built successfully'); |
| 42 | + } catch (error) { |
| 43 | + throw new Error(`Bundler build failed: ${(error as Error).message}`); |
| 44 | + } |
57 | 45 | } |
58 | 46 |
|
59 | 47 | /** |
60 | 48 | * Execute the bundler CLI with provided arguments |
61 | 49 | */ |
62 | 50 | async function executeBundler(args: string[]): Promise<void> { |
63 | | - return new Promise((resolve, reject) => { |
64 | | - const child = spawn('node', [BUNDLER_CLI, ...args], { |
| 51 | + try { |
| 52 | + execSync(`node "${BUNDLER_CLI}" ${args.join(' ')}`, { |
65 | 53 | stdio: 'inherit', |
66 | | - shell: false, |
67 | | - }); |
68 | | - |
69 | | - child.on('close', (code) => { |
70 | | - if (code === 0) { |
71 | | - resolve(); |
72 | | - } else { |
73 | | - reject(new Error(`Bundler execution failed with code ${code}`)); |
74 | | - } |
75 | 54 | }); |
76 | | - |
77 | | - child.on('error', reject); |
78 | | - }); |
| 55 | + } catch (error) { |
| 56 | + throw new Error(`Bundler execution failed: ${(error as Error).message}`); |
| 57 | + } |
79 | 58 | } |
80 | 59 |
|
81 | 60 | /** |
|
0 commit comments