|
1 | 1 | process.env.NODE_ENV = 'development'; |
2 | 2 |
|
3 | 3 | import * as Vite from 'vite'; |
4 | | -import ChildProcess from 'child_process'; |
| 4 | +import ChildProcess, { type ChildProcessWithoutNullStreams } from 'child_process'; |
5 | 5 | import Path from 'path'; |
6 | 6 | import Chalk from 'chalk'; |
7 | 7 | import Chokidar from 'chokidar'; |
8 | 8 | import Electron from 'electron'; |
9 | | -import compileTs from './private/tsc.js'; |
| 9 | +import compileTs from './private/tsc.ts'; |
| 10 | +// ^ Extension needed because no TSConfig in the root |
10 | 11 | import FileSystem from 'fs'; |
11 | 12 | import { EOL } from 'os'; |
12 | 13 | import { fileURLToPath } from 'url'; |
13 | 14 |
|
14 | 15 | const __filename = fileURLToPath(import.meta.url); |
15 | 16 | const __dirname = Path.dirname(__filename); |
16 | 17 |
|
17 | | -let viteServer = null; |
18 | | -let electronProcess = null; |
| 18 | +let viteServer: Vite.ViteDevServer | null = null; |
| 19 | +let electronProcess: ChildProcessWithoutNullStreams | null = null; |
19 | 20 | let electronProcessLocker = false; |
20 | 21 | let rendererPort = 0; |
21 | 22 |
|
@@ -44,24 +45,25 @@ async function startElectron() { |
44 | 45 |
|
45 | 46 | const args = [ |
46 | 47 | Path.join(__dirname, '..', 'build', 'main', 'main.js'), |
47 | | - rendererPort, |
| 48 | + String(rendererPort), |
48 | 49 | ]; |
49 | | - electronProcess = ChildProcess.spawn(Electron, args); |
| 50 | + |
| 51 | + electronProcess = ChildProcess.spawn(String(Electron), args); |
50 | 52 | electronProcessLocker = false; |
51 | 53 |
|
52 | | - electronProcess.stdout.on('data', data => { |
| 54 | + electronProcess!.stdout.on('data', data => { |
53 | 55 | if (data == EOL) { |
54 | 56 | return; |
55 | 57 | } |
56 | 58 |
|
57 | 59 | process.stdout.write(Chalk.blueBright(`[electron] `) + Chalk.white(data.toString())) |
58 | 60 | }); |
59 | 61 |
|
60 | | - electronProcess.stderr.on('data', data => |
| 62 | + electronProcess!.stderr.on('data', data => |
61 | 63 | process.stderr.write(Chalk.blueBright(`[electron] `) + Chalk.white(data.toString())) |
62 | 64 | ); |
63 | 65 |
|
64 | | - electronProcess.on('exit', () => stop()); |
| 66 | + electronProcess!.on('exit', () => stop()); |
65 | 67 | } |
66 | 68 |
|
67 | 69 | function restartElectron() { |
@@ -94,7 +96,7 @@ function copy(path) { |
94 | 96 | } |
95 | 97 |
|
96 | 98 | function stop() { |
97 | | - viteServer.close(); |
| 99 | + viteServer!.close(); |
98 | 100 | process.exit(); |
99 | 101 | } |
100 | 102 |
|
|
0 commit comments