Skip to content

Commit

Permalink
fix: only import default config if no userConfig is passed (#1302)
Browse files Browse the repository at this point in the history
* only import default config if no userConfig is passed

#1202

* test: only import default config if no userConfig is passed
  • Loading branch information
adrai committed Jul 6, 2021
1 parent 45617ca commit 28cd9c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/serverSideTranslations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('serverSideTranslations', () => {
locales: ['en-US', 'fr-CA'],
},
} as UserConfig)
expect(fs.existsSync).toHaveBeenCalledTimes(0)
expect(fs.readdirSync).toHaveBeenCalledTimes(1)
expect(fs.readdirSync).toHaveBeenCalledWith(expect.stringMatching('/public/locales/en-US'))
expect(props._nextI18Next.initialI18nStore)
Expand Down
2 changes: 1 addition & 1 deletion src/serverSideTranslations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const serverSideTranslations = async (

let userConfig = configOverride

if (fs.existsSync(path.resolve(DEFAULT_CONFIG_PATH))) {
if (!userConfig && fs.existsSync(path.resolve(DEFAULT_CONFIG_PATH))) {
userConfig = await import(path.resolve(DEFAULT_CONFIG_PATH))
}

Expand Down

1 comment on commit 28cd9c6

@vercel
Copy link

@vercel vercel bot commented on 28cd9c6 Jul 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.