mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 20:07:06 +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 query = new URLSearchParams(import.meta.url.split('?')[1])
|
||||||
const debug = query.has('debug')
|
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>}
|
* @type {(server: import('vite').ViteDevServer) => Promise<import('rollup').RollupWatcher>}
|
||||||
*/
|
*/
|
||||||
@ -25,6 +33,7 @@ function watchMain(server) {
|
|||||||
const startElectron = {
|
const startElectron = {
|
||||||
name: 'electron-main-watcher',
|
name: 'electron-main-watcher',
|
||||||
writeBundle() {
|
writeBundle() {
|
||||||
|
clearConsole()
|
||||||
electronProcess && electronProcess.kill()
|
electronProcess && electronProcess.kill()
|
||||||
electronProcess = spawn(electron, ['.'], { stdio: 'inherit', env })
|
electronProcess = spawn(electron, ['.'], { stdio: 'inherit', env })
|
||||||
},
|
},
|
||||||
@ -50,6 +59,7 @@ function watchPreload(server) {
|
|||||||
plugins: [{
|
plugins: [{
|
||||||
name: 'electron-preload-watcher',
|
name: 'electron-preload-watcher',
|
||||||
writeBundle() {
|
writeBundle() {
|
||||||
|
clearConsole()
|
||||||
server.ws.send({ type: 'full-reload' })
|
server.ws.send({ type: 'full-reload' })
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user