mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
feat: add clear console function in watch script
This commit is contained in:
parent
41eafc6252
commit
8089ebcb90
@ -6,6 +6,14 @@ import readline from 'readline'
|
||||
const query = new URLSearchParams(import.meta.url.split('?')[1])
|
||||
const debug = query.has('debug')
|
||||
|
||||
/** The log will display on the next screen */
|
||||
function clearConsole() {
|
||||
const blank = '\n'.repeat(process.stdout.rows)
|
||||
console.log(blank)
|
||||
readline.cursorTo(process.stdout, 0, 0)
|
||||
readline.clearScreenDown(process.stdout)
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {(server: import('vite').ViteDevServer) => Promise<import('rollup').RollupWatcher>}
|
||||
*/
|
||||
@ -25,6 +33,7 @@ function watchMain(server) {
|
||||
const startElectron = {
|
||||
name: 'electron-main-watcher',
|
||||
writeBundle() {
|
||||
clearConsole()
|
||||
electronProcess && electronProcess.kill()
|
||||
electronProcess = spawn(electron, ['.'], { stdio: 'inherit', env })
|
||||
},
|
||||
@ -50,6 +59,7 @@ function watchPreload(server) {
|
||||
plugins: [{
|
||||
name: 'electron-preload-watcher',
|
||||
writeBundle() {
|
||||
clearConsole()
|
||||
server.ws.send({ type: 'full-reload' })
|
||||
},
|
||||
}],
|
||||
|
Loading…
x
Reference in New Issue
Block a user