diff options
author | 2022-08-13 00:09:58 -0700 | |
---|---|---|
committer | 2022-08-13 00:09:58 -0700 | |
commit | 73f367c77b8311707b1c142e03dd53952f14d934 (patch) | |
tree | 5dba4800d8b1cba89cf78303979431143d544b8a | |
parent | d54588c7a4adfa05969713111d36673f3a9b988e (diff) | |
download | astro-73f367c77b8311707b1c142e03dd53952f14d934.tar.gz astro-73f367c77b8311707b1c142e03dd53952f14d934.tar.zst astro-73f367c77b8311707b1c142e03dd53952f14d934.zip |
add protection if astro preview is run with server output (#4284)
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
-rw-r--r-- | .changeset/yellow-insects-add.md | 5 | ||||
-rw-r--r-- | packages/astro/src/cli/index.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/core/preview/index.ts | 3 | ||||
-rw-r--r-- | packages/astro/test/cli.test.js | 3 |
4 files changed, 10 insertions, 3 deletions
diff --git a/.changeset/yellow-insects-add.md b/.changeset/yellow-insects-add.md new file mode 100644 index 000000000..7454f9c4c --- /dev/null +++ b/.changeset/yellow-insects-add.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Prevent preview if 'output: server' is configured diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index d1e85301f..2511ada86 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -37,7 +37,7 @@ function printAstroHelp() { printHelp({ commandName: 'astro', usage: '[command] [...flags]', - headline: 'Futuristic web development tool.', + headline: 'Build faster websites.', tables: { Commands: [ ['add', 'Add an integration.'], diff --git a/packages/astro/src/core/preview/index.ts b/packages/astro/src/core/preview/index.ts index 33392831c..9453fdf65 100644 --- a/packages/astro/src/core/preview/index.ts +++ b/packages/astro/src/core/preview/index.ts @@ -33,6 +33,9 @@ export default async function preview( config: AstroConfig, { logging }: PreviewOptions ): Promise<PreviewServer> { + if (config.output === 'server') { + throw new Error(`[preview] 'output: server' not supported. Use your deploy platform's preview command directly instead, if one exists. (ex: 'netlify dev', 'vercel dev', 'wrangler', etc.)`); + } const startServerTime = performance.now(); const defaultOrigin = 'http://localhost'; const trailingSlash = config.trailingSlash; diff --git a/packages/astro/test/cli.test.js b/packages/astro/test/cli.test.js index 38d8964c2..50364bd57 100644 --- a/packages/astro/test/cli.test.js +++ b/packages/astro/test/cli.test.js @@ -12,8 +12,7 @@ describe('astro cli', () => { it('astro', async () => { const proc = await cli(); - - expect(proc.stdout).to.include('Futuristic web development tool'); + expect(proc.exitCode).to.equal(0); }); it('astro --version', async () => { |