add protection if astro preview is run with server output (#4284)

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
Fred K. Schott 2022-08-13 00:09:58 -07:00 committed by GitHub
parent d54588c7a4
commit 73f367c77b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Prevent preview if 'output: server' is configured

View file

@ -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.'],

View file

@ -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;

View file

@ -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 () => {