feat: add noElectronStart CLI option to the dev command

This commit is contained in:
Erik Moura 2024-07-31 23:24:09 -03:00
parent 02e0dff9f4
commit 03936a31f8
No known key found for this signature in database
GPG Key ID: 327E80DF4879EE47
2 changed files with 8 additions and 4 deletions

View File

@ -32,6 +32,7 @@ interface DevCLIOptions {
inspect?: boolean | string inspect?: boolean | string
inspectBrk?: boolean | string inspectBrk?: boolean | string
remoteDebuggingPort?: string remoteDebuggingPort?: string
noElectronStart?: boolean
noSandbox?: boolean noSandbox?: boolean
rendererOnly?: boolean rendererOnly?: boolean
} }
@ -78,6 +79,7 @@ cli
.option('--inspect [port]', `[boolean | number] enable V8 inspector on the specified port`) .option('--inspect [port]', `[boolean | number] enable V8 inspector on the specified port`)
.option('--inspectBrk [port]', `[boolean | number] enable V8 inspector on the specified port`) .option('--inspectBrk [port]', `[boolean | number] enable V8 inspector on the specified port`)
.option('--remoteDebuggingPort <port>', `[string] port for remote debugging`) .option('--remoteDebuggingPort <port>', `[string] port for remote debugging`)
.option('--noElectronStart', `[boolean] run dev servers without starting the Electron app`)
.option('--noSandbox', `[boolean] forces renderer process to run un-sandboxed`) .option('--noSandbox', `[boolean] forces renderer process to run un-sandboxed`)
.option('--rendererOnly', `[boolean] only dev server for the renderer`) .option('--rendererOnly', `[boolean] only dev server for the renderer`)
.action(async (root: string, options: DevCLIOptions & GlobalCLIOptions) => { .action(async (root: string, options: DevCLIOptions & GlobalCLIOptions) => {
@ -109,7 +111,7 @@ cli
const inlineConfig = createInlineConfig(root, options) const inlineConfig = createInlineConfig(root, options)
try { try {
await createServer(inlineConfig, { rendererOnly: options.rendererOnly }) await createServer(inlineConfig, { rendererOnly: options.rendererOnly, noElectronStart: options.noElectronStart })
} catch (e) { } catch (e) {
const error = e as Error const error = e as Error
createLogger(options.logLevel).error( createLogger(options.logLevel).error(

View File

@ -14,7 +14,7 @@ import { startElectron } from './electron'
export async function createServer( export async function createServer(
inlineConfig: InlineConfig = {}, inlineConfig: InlineConfig = {},
options: { rendererOnly?: boolean } options: { rendererOnly?: boolean; noElectronStart?: boolean }
): Promise<void> { ): Promise<void> {
process.env.NODE_ENV_ELECTRON_VITE = 'development' process.env.NODE_ENV_ELECTRON_VITE = 'development'
const config = await resolveConfig(inlineConfig, 'serve', 'development') const config = await resolveConfig(inlineConfig, 'serve', 'development')
@ -104,9 +104,11 @@ export async function createServer(
server.printUrls() server.printUrls()
} }
ps = startElectron(inlineConfig.root) if(!options.noElectronStart) {
ps = startElectron(inlineConfig.root)
logger.info(colors.green(`\nstart electron app...\n`)) logger.info(colors.green(`\nstart electron app...\n`))
}
} }
} }