MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / saveConfig

Function saveConfig

src/utils/config.ts:1124–1153  ·  view source on GitHub ↗
(
  file: string,
  config: A,
  defaultConfig: A,
)

Source from the content-addressed store, hash-verified

1122}
1123
1124function saveConfig<A extends object>(
1125 file: string,
1126 config: A,
1127 defaultConfig: A,
1128): void {
1129 // Ensure the directory exists before writing the config file
1130 const dir = dirname(file)
1131 const fs = getFsImplementation()
1132 // mkdirSync is already recursive in FsOperations implementation
1133 fs.mkdirSync(dir)
1134
1135 // Filter out any values that match the defaults
1136 const filteredConfig = pickBy(
1137 config,
1138 (value, key) =>
1139 jsonStringify(value) !== jsonStringify(defaultConfig[key as keyof A]),
1140 )
1141 // Write config file with secure permissions - mode only applies to new files
1142 writeFileSyncAndFlush_DEPRECATED(
1143 file,
1144 jsonStringify(filteredConfig, null, 2),
1145 {
1146 encoding: 'utf-8',
1147 mode: 0o600,
1148 },
1149 )
1150 if (file === getGlobalClaudeFile()) {
1151 globalConfigWriteCount++
1152 }
1153}
1154
1155/**
1156 * Returns true if a write was performed; false if the write was skipped

Callers 2

saveGlobalConfigFunction · 0.85
saveCurrentProjectConfigFunction · 0.85

Calls 3

getFsImplementationFunction · 0.85
jsonStringifyFunction · 0.85

Tested by

no test coverage detected