Skip to content

Commit b275d52

Browse files
strickvlclaude
andcommitted
refactor: remove redundant custom-strings validation and global variable
Remove duplicate validation in cli.ts since comprehensive validation already exists in loadCustomStrings(). Also eliminate unnecessary customStrings global variable by using customStringsData directly. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2b2819e commit b275d52

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

src/node/cli.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -466,20 +466,6 @@ export const parse = (
466466
throw new Error("--cert-key is missing")
467467
}
468468

469-
// Validate custom-strings flag
470-
if (args["custom-strings"]) {
471-
try {
472-
// First try to parse as JSON directly
473-
JSON.parse(args["custom-strings"])
474-
} catch (jsonError) {
475-
// If JSON parsing fails, check if it's a valid file path
476-
if (!args["custom-strings"].startsWith("{") && !args["custom-strings"].startsWith("[")) {
477-
// Assume it's a file path - validation will happen later when the file is read
478-
} else {
479-
throw error(`--custom-strings contains invalid JSON: ${jsonError instanceof Error ? jsonError.message : String(jsonError)}`)
480-
}
481-
}
482-
}
483469

484470
logger.debug(() => [`parsed ${opts?.configFile ? "config" : "command line"}`, field("args", redactArgs(args))])
485471

src/node/i18n/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const defaultResources = {
2424
},
2525
}
2626

27-
let customStrings: Record<string, any> = {}
2827

2928
export async function loadCustomStrings(customStringsArg?: string): Promise<void> {
3029
if (!customStringsArg) {
@@ -43,15 +42,13 @@ export async function loadCustomStrings(customStringsArg?: string): Promise<void
4342
customStringsData = JSON.parse(fileContent)
4443
}
4544

46-
customStrings = customStringsData
47-
4845
// Re-initialize i18next with merged resources
4946
const mergedResources = Object.keys(defaultResources).reduce((acc, lang) => {
5047
const langKey = lang as keyof typeof defaultResources
5148
acc[langKey] = {
5249
translation: {
5350
...defaultResources[langKey].translation,
54-
...customStrings,
51+
...customStringsData,
5552
},
5653
}
5754
return acc

0 commit comments

Comments
 (0)