refactor(core): remove useless build forceTerminate exit (#10410)

This commit is contained in:
Sébastien Lorber 2024-08-19 14:17:13 +02:00 committed by GitHub
parent ae5328daac
commit 3a0b4bf7a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 23 deletions

View file

@ -48,11 +48,6 @@ export type BuildCLIOptions = Pick<
export async function build(
siteDirParam: string = '.',
cliOptions: Partial<BuildCLIOptions> = {},
// 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<void> {
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({

View file

@ -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.');

View file

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