From 3a0b4bf7a2937fcad134e99684f365de25bbf7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Mon, 19 Aug 2024 14:17:13 +0200 Subject: [PATCH] refactor(core): remove useless build forceTerminate exit (#10410) --- packages/docusaurus/src/commands/build.ts | 16 ++-------------- packages/docusaurus/src/commands/deploy.ts | 2 +- packages/docusaurus/src/commands/serve.ts | 12 ++++-------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/packages/docusaurus/src/commands/build.ts b/packages/docusaurus/src/commands/build.ts index dee3fc8869ea..cc587d24f033 100644 --- a/packages/docusaurus/src/commands/build.ts +++ b/packages/docusaurus/src/commands/build.ts @@ -48,11 +48,6 @@ export type BuildCLIOptions = Pick< export async function build( siteDirParam: string = '.', cliOptions: Partial = {}, - // When running build, we force terminate the process to prevent async - // operations from never returning. However, if run as part of docusaurus - // deploy, we have to let deploy finish. - // See https://github.com/facebook/docusaurus/pull/2496 - forceTerminate: boolean = true, ): Promise { process.env.BABEL_ENV = 'production'; process.env.NODE_ENV = 'production'; @@ -98,18 +93,11 @@ export async function build( await PerfLogger.async(`Build`, () => mapAsyncSequential(locales, async (locale) => { - const isLastLocale = locales.indexOf(locale) === locales.length - 1; await tryToBuildLocale({locale}); - if (isLastLocale) { - logger.info`Use code=${'npm run serve'} command to test your build locally.`; - } - - // TODO do we really need this historical forceTerminate exit??? - if (forceTerminate && isLastLocale && !cliOptions.bundleAnalyzer) { - process.exit(0); - } }), ); + + logger.info`Use code=${'npm run serve'} command to test your build locally.`; } async function getLocalesToBuild({ diff --git a/packages/docusaurus/src/commands/deploy.ts b/packages/docusaurus/src/commands/deploy.ts index 2e23a8e3efb1..f2b1471642ab 100644 --- a/packages/docusaurus/src/commands/deploy.ts +++ b/packages/docusaurus/src/commands/deploy.ts @@ -256,7 +256,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`); if (!cliOptions.skipBuild) { // Build site, then push to deploymentBranch branch of specified repo. try { - await build(siteDir, cliOptions, false); + await build(siteDir, cliOptions); await runDeploy(outDir); } catch (err) { logger.error('Deployment of the build output failed.'); diff --git a/packages/docusaurus/src/commands/serve.ts b/packages/docusaurus/src/commands/serve.ts index a4b0acf1fcb1..002b04564ec6 100644 --- a/packages/docusaurus/src/commands/serve.ts +++ b/packages/docusaurus/src/commands/serve.ts @@ -42,14 +42,10 @@ export async function serve( const outDir = path.resolve(siteDir, buildDir); if (cliOptions.build) { - await build( - siteDir, - { - config: cliOptions.config, - outDir, - }, - false, - ); + await build(siteDir, { + config: cliOptions.config, + outDir, + }); } const {host, port} = await getHostPort(cliOptions);