fix: pass flags to dev (#5840)

* fix: pass flags to dev

* add changeset

* Update .changeset/eleven-bulldogs-provide.md

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
Sam Chen 2023-01-13 00:06:44 +08:00 committed by GitHub
parent c4b0cb8bf2
commit cf2de5422c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Persist CLI flags when restarting the dev server

View file

@ -189,6 +189,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
await devServer(settings, {
configFlag,
configFlagPath,
flags,
logging,
telemetry,
handleConfigError(e) {

View file

@ -3,6 +3,7 @@ import type http from 'http';
import type { AddressInfo } from 'net';
import { performance } from 'perf_hooks';
import * as vite from 'vite';
import yargs from 'yargs-parser';
import type { AstroSettings } from '../../@types/astro';
import { info, LogOptions, warn } from '../logger/core.js';
import * as msg from '../messages.js';
@ -12,6 +13,7 @@ import { createContainerWithAutomaticRestart } from './restart.js';
export interface DevOptions {
configFlag: string | undefined;
configFlagPath: string | undefined;
flags: yargs.Arguments | undefined;
logging: LogOptions;
telemetry: AstroTelemetry;
handleConfigError: (error: Error) => void;
@ -35,7 +37,7 @@ export default async function dev(
// Create a container which sets up the Vite server.
const restart = await createContainerWithAutomaticRestart({
flags: {},
flags: options.flags ?? {},
handleConfigError: options.handleConfigError,
// eslint-disable-next-line no-console
beforeRestart: () => console.clear(),