Skip to content

Commit

Permalink
fix: pass flags to dev (#5840)
Browse files Browse the repository at this point in the history
* fix: pass flags to dev

* add changeset

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

Co-authored-by: Nate Moore <[email protected]>
  • Loading branch information
chenxsan and natemoo-re committed Jan 12, 2023
1 parent c4b0cb8 commit cf2de54
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eleven-bulldogs-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Persist CLI flags when restarting the dev server
1 change: 1 addition & 0 deletions packages/astro/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
await devServer(settings, {
configFlag,
configFlagPath,
flags,
logging,
telemetry,
handleConfigError(e) {
Expand Down
4 changes: 3 additions & 1 deletion packages/astro/src/core/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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(),
Expand Down

0 comments on commit cf2de54

Please sign in to comment.