Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed May 25, 2022
1 parent d8b61fe commit d75a0cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ exports[`loadSiteConfig website with .cjs siteConfig 1`] = `
"siteConfig": {
"baseUrl": "/",
"baseUrlIssueBanner": true,
"clientModules": [
"foo.js",
],
"clientModules": [],
"customFields": {},
"favicon": "img/docusaurus.ico",
"i18n": {
"defaultLocale": "en",
"localeConfigs": {},
Expand All @@ -21,31 +18,21 @@ exports[`loadSiteConfig website with .cjs siteConfig 1`] = `
"onBrokenLinks": "throw",
"onBrokenMarkdownLinks": "warn",
"onDuplicateRoutes": "warn",
"organizationName": "endiliey",
"plugins": [
[
"@docusaurus/plugin-content-docs",
{
"path": "../docs",
},
],
"@docusaurus/plugin-content-pages",
],
"plugins": [],
"presets": [],
"projectName": "hello",
"scripts": [],
"staticDirectories": [
"static",
],
"stylesheets": [],
"tagline": "Hello World",
"tagline": "",
"themeConfig": {},
"themes": [],
"title": "Hello",
"title": "title",
"titleDelimiter": "|",
"url": "https://docusaurus.io",
"url": "https://example.com",
},
"siteConfigPath": "<PROJECT_ROOT>/packages/docusaurus/src/server/__tests__/__fixtures__/simple-site/docusaurus.config.js",
"siteConfigPath": "<PROJECT_ROOT>/packages/docusaurus/src/server/__tests__/__fixtures__/config/docusaurus.config.cjs",
}
`;

Expand Down
4 changes: 1 addition & 3 deletions packages/docusaurus/src/server/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ describe('loadSiteConfig', () => {
});

it('website with .cjs siteConfig', async () => {
const config = await loadSiteConfig({
siteDir: path.join(__dirname, '__fixtures__', 'simple-site'),
});
const config = await loadSiteConfig({siteDir});
expect(config).toMatchSnapshot();
expect(config).not.toEqual({});
});
Expand Down
5 changes: 3 additions & 2 deletions packages/docusaurus/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {LoadContext} from '@docusaurus/types';

async function findConfig(siteDir: string) {
// We could support .mjs, .ts, etc. in the future
const candidates = ['.js', 'cjs'].map(
const candidates = ['.js', '.cjs'].map(
(ext) => DEFAULT_CONFIG_FILE_NAME + ext,
);
const configPath = await findAsyncSequential(
Expand All @@ -24,7 +24,8 @@ async function findConfig(siteDir: string) {
);
if (!configPath) {
logger.error('No config file found.');
logger.info`Expected one of:${candidates}You can provide a custom config path with the code=${'--config'} option.`;
logger.info`Expected one of:${candidates}
You can provide a custom config path with the code=${'--config'} option.`;
throw new Error();
}
return configPath;
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ next build. You can clear all build artifacts (including this folder) with the

const genSiteConfig = generate(
generatedFilesDir,
DEFAULT_CONFIG_FILE_NAME,
`${DEFAULT_CONFIG_FILE_NAME}.mjs`,
`/*
* AUTOGENERATED - DON'T EDIT
* Your edits in this file will be overwritten in the next build!
Expand Down

0 comments on commit d75a0cd

Please sign in to comment.