Skip to content

Commit

Permalink
fix(#5985): preserve --root CLI flag on restart
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Feb 6, 2023
1 parent 327a76c commit 5871cc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-planes-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Preserve `--root` CLI flag when restarting dev server
5 changes: 3 additions & 2 deletions packages/astro/src/core/dev/restart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export async function restartContainer({
beforeRestart,
}: RestartContainerParams): Promise<{ container: Container; error: Error | null }> {
const { logging, close, resolvedRoot, settings: existingSettings } = container;
const root = flags.root || resolvedRoot;
container.restartInFlight = true;

if (beforeRestart) {
Expand All @@ -84,7 +85,7 @@ export async function restartContainer({
const needsStart = isStarted(container);
try {
const newConfig = await openConfig({
cwd: resolvedRoot,
cwd: root,
flags,
cmd: 'dev',
logging,
Expand All @@ -93,7 +94,7 @@ export async function restartContainer({
});
info(logging, 'astro', logMsg + '\n');
let astroConfig = newConfig.astroConfig;
const settings = createSettings(astroConfig, resolvedRoot);
const settings = createSettings(astroConfig, root);
await close();
return {
container: await createRestartedContainer(container, settings, needsStart),
Expand Down

0 comments on commit 5871cc9

Please sign in to comment.