Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Aug 21, 2024
1 parent 4135595 commit d4967d9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/vike-node/src/plugin/plugins/devServerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { logViteInfo } from '../utils/logVite.js'
let viteDevServer: ViteDevServer
const VITE_HMR_PATH = '/__vite_hmr'
const RESTART_EXIT_CODE = 33
const IS_RESTARTER_SETUP = '__VIKE__IS_RESTARTER_SETUP'
const IS_RESTARTER_SET_UP = '__VIKE__IS_RESTARTER_SET_UP'

export function devServerPlugin(): Plugin {
let resolvedConfig: ConfigVikeNodeResolved
Expand Down Expand Up @@ -150,11 +150,11 @@ function setupErrorHandler(vite: ViteDevServer) {
process.on('uncaughtException', onError)
}

// The CLI root process is blocked and, instead, it orchestrates server restarts.
// The same CLI is called as a child process which does the actual work.
// We hijack the CLI root process: we block Vite and make it orchestrates server restarts instead.
// We execute the CLI again as a child process which does the actual work.
async function setupProcessRestarter() {
if (isRestarterSetup()) return
process.env[IS_RESTARTER_SETUP] = 'true'
if (isRestarterSetUp()) return
process.env[IS_RESTARTER_SET_UP] = 'true'

function start() {
const cliEntry = process.argv[1]!
Expand All @@ -171,16 +171,16 @@ async function setupProcessRestarter() {
}
start()

// Trick: never resolve promise in order to block the CLI root process
// Trick: never-resolving-promise in order to block the CLI root process
await new Promise(() => {})
}

function isRestarterSetup() {
return process.env[IS_RESTARTER_SETUP] === 'true'
function isRestarterSetUp() {
return process.env[IS_RESTARTER_SET_UP] === 'true'
}

function restartProcess() {
logViteInfo('Restarting server...')
assert(isRestarterSetup())
assert(isRestarterSetUp())
process.exit(RESTART_EXIT_CODE)
}

0 comments on commit d4967d9

Please sign in to comment.