Skip to content

Commit 4c121a7

Browse files
committed
chore: copy default locale
1 parent c8c7b79 commit 4c121a7

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/helpers/files.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -241,22 +241,23 @@ export const moveStaticPages = async ({
241241
await writeJson(join(netlifyConfig.build.publish, 'static-manifest.json'), Object.entries(filesManifest))
242242

243243
if (i18n?.defaultLocale) {
244+
const rootPath = basePath ? join(netlifyConfig.build.publish, basePath) : netlifyConfig.build.publish
244245
// Copy the default locale into the root
245-
const defaultLocaleDir = join(netlifyConfig.build.publish, i18n.defaultLocale)
246+
const defaultLocaleDir = join(rootPath, i18n.defaultLocale)
246247
if (existsSync(defaultLocaleDir)) {
247-
await copy(defaultLocaleDir, `${netlifyConfig.build.publish}/`)
248+
await copy(defaultLocaleDir, `${rootPath}/`)
248249
}
249-
const defaultLocaleIndex = join(netlifyConfig.build.publish, `${i18n.defaultLocale}.html`)
250-
const indexHtml = join(netlifyConfig.build.publish, 'index.html')
250+
const defaultLocaleIndex = join(rootPath, `${i18n.defaultLocale}.html`)
251+
const indexHtml = join(rootPath, 'index.html')
251252
if (existsSync(defaultLocaleIndex) && !existsSync(indexHtml)) {
252-
try {
253-
await copy(defaultLocaleIndex, indexHtml, { overwrite: false })
254-
await copy(
255-
join(netlifyConfig.build.publish, `${i18n.defaultLocale}.json`),
256-
join(netlifyConfig.build.publish, 'index.json'),
257-
{ overwrite: false },
258-
)
259-
} catch {}
253+
await copy(defaultLocaleIndex, indexHtml, { overwrite: false }).catch(() => {
254+
/* ignore */
255+
})
256+
await copy(join(rootPath, `${i18n.defaultLocale}.json`), join(rootPath, 'index.json'), {
257+
overwrite: false,
258+
}).catch(() => {
259+
/* ignore */
260+
})
260261
}
261262
}
262263

0 commit comments

Comments
 (0)