mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 15:31:16 +08:00
Merge pull request #20243 from storybookjs/20242-handle-bail-better
Vite: Make the bail function work if the server fails to start
This commit is contained in:
commit
f4f79893b2
@ -69,14 +69,8 @@ function iframeMiddleware(options: ExtendedOptions, server: ViteDevServer): Requ
|
||||
|
||||
let server: ViteDevServer;
|
||||
|
||||
export async function bail(e?: Error): Promise<void> {
|
||||
try {
|
||||
return await server.close();
|
||||
} catch (err) {
|
||||
console.warn('unable to close vite server');
|
||||
}
|
||||
|
||||
throw e;
|
||||
export async function bail(): Promise<void> {
|
||||
return server?.close();
|
||||
}
|
||||
|
||||
export const start: ViteBuilder['start'] = async ({
|
||||
|
@ -3,19 +3,16 @@
|
||||
|
||||
import { createViteServer } from './vite-server';
|
||||
|
||||
|
||||
let server: ViteDevServer;
|
||||
export async function bail(): Promise<void> {
|
||||
return server?.close();
|
||||
}
|
||||
|
||||
export const start: ViteBuilder['start'] = async ({ options, server: devServer }) => {
|
||||
// Remainder implementation goes here
|
||||
|
||||
const server = await createViteServer(options as ExtendedOptions, devServer);
|
||||
async function bail(e?: Error): Promise<void> {
|
||||
try {
|
||||
return await server.close();
|
||||
} catch (err) {
|
||||
console.warn('unable to close the server');
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
server = await createViteServer(options as ExtendedOptions, devServer);
|
||||
|
||||
return {
|
||||
bail,
|
||||
totalTime: process.hrtime(startTime),
|
||||
|
Loading…
x
Reference in New Issue
Block a user