Skip to content

Commit 3cd5e5b

Browse files
committed
fix issues found be coderabbit ai.
1 parent f0ffd99 commit 3cd5e5b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/cli/translate.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,7 @@ export const translateCommand = new Command('translate')
478478

479479
targetFrontmatter = matter(targetContent).data as I18nFrontmatter
480480

481-
if (
482-
sourceFrontmatter.i18n?.disableAutoTranslation ||
483-
(!force && targetFrontmatter.sourceSHA === sourceSHA)
484-
) {
481+
if (!force && targetFrontmatter.sourceSHA === sourceSHA) {
485482
allSourceFilePaths.delete(sourceFilePath)
486483
return
487484
}
@@ -577,13 +574,18 @@ export const translateCommand = new Command('translate')
577574
}
578575
}
579576

580-
if (typeof newFrontmatter.title !== 'string') {
581-
delete newFrontmatter.title
582-
}
577+
const finalFrontmatter =
578+
typeof newFrontmatter.title === 'string'
579+
? newFrontmatter
580+
: (() => {
581+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
582+
const { title: _, ...rest } = newFrontmatter
583+
return rest
584+
})()
583585

584586
targetContent = matter.stringify(
585587
content.startsWith('\n') ? content : '\n' + content,
586-
newFrontmatter,
588+
finalFrontmatter,
587589
)
588590

589591
await fs.mkdir(targetBase, { recursive: true })

0 commit comments

Comments
 (0)