()
| 105 | } |
| 106 | |
| 107 | async function start() { |
| 108 | console.log( |
| 109 | `${Chalk.greenBright("=======================================")}` |
| 110 | ) |
| 111 | console.log( |
| 112 | `${Chalk.greenBright("Starting Electron + Vite Dev Server...")}` |
| 113 | ) |
| 114 | console.log( |
| 115 | `${Chalk.greenBright("=======================================")}` |
| 116 | ) |
| 117 | |
| 118 | if(rimrafSync(Path.join(__dirname, "..", "build"))) { |
| 119 | console.log(Chalk.greenBright("Build folder deleted.")) |
| 120 | |
| 121 | copyStaticFiles() |
| 122 | |
| 123 | ChildProcess.exec("yarn php:compile", { |
| 124 | cwd: Path.join(__dirname, ".."), |
| 125 | }, (error, stdout, stderr) => { |
| 126 | if (error) { |
| 127 | console.log(Chalk.redBright(error)) |
| 128 | process.exit(1) |
| 129 | } |
| 130 | |
| 131 | if (stderr) { |
| 132 | console.log(Chalk.redBright(stderr)) |
| 133 | process.exit(1) |
| 134 | } |
| 135 | |
| 136 | console.log(Chalk.greenBright(stdout)) |
| 137 | }) |
| 138 | } |
| 139 | |
| 140 | const devServer = await startRenderer() |
| 141 | rendererPort = devServer.config.server.port |
| 142 | |
| 143 | console.log(`Using port ${rendererPort} for renderer process.`) |
| 144 | |
| 145 | startElectron() |
| 146 | |
| 147 | const path = Path.join(__dirname, "..", "src", "main") |
| 148 | Chokidar.watch(path, { |
| 149 | cwd: path, |
| 150 | ignored: [ |
| 151 | Path.join(path, "static"), |
| 152 | ], |
| 153 | }).on("change", (path) => { |
| 154 | console.log( |
| 155 | Chalk.blueBright(`[electron] `) + |
| 156 | `Change in ${path}. Reloading... 🚀` |
| 157 | ) |
| 158 | |
| 159 | if (path.startsWith(Path.join("static", "/"))) { |
| 160 | copy(path) |
| 161 | } |
| 162 | |
| 163 | restartElectron() |
| 164 | }) |
no test coverage detected