From cf2de5422c26bfdea4c75f76e57b57299ded3e3a Mon Sep 17 00:00:00 2001 From: Sam Chen Date: Fri, 13 Jan 2023 00:06:44 +0800 Subject: [PATCH] fix: pass flags to dev (#5840) * fix: pass flags to dev * add changeset * Update .changeset/eleven-bulldogs-provide.md Co-authored-by: Nate Moore --- .changeset/eleven-bulldogs-provide.md | 5 +++++ packages/astro/src/cli/index.ts | 1 + packages/astro/src/core/dev/dev.ts | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/eleven-bulldogs-provide.md diff --git a/.changeset/eleven-bulldogs-provide.md b/.changeset/eleven-bulldogs-provide.md new file mode 100644 index 000000000000..e8ae0f16cc9b --- /dev/null +++ b/.changeset/eleven-bulldogs-provide.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Persist CLI flags when restarting the dev server diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index a1f5a54f81f4..27c2a323cbb8 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -189,6 +189,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) { await devServer(settings, { configFlag, configFlagPath, + flags, logging, telemetry, handleConfigError(e) { diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index 074501b04a34..9682ac796fb6 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -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(),