Skip to content

Commit

Permalink
refactor(core): remove useless build forceTerminate exit (facebook#10410
Browse files Browse the repository at this point in the history
)
  • Loading branch information
slorber authored Aug 19, 2024
1 parent ae5328d commit 3a0b4bf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
16 changes: 2 additions & 14 deletions packages/docusaurus/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
12 changes: 4 additions & 8 deletions packages/docusaurus/src/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3a0b4bf

Please sign in to comment.