( scope: WriteScope, cwd: string, homedirOverride?: string, )
| 50 | export type WriteConfigPatchResult = Result<WriteConfigPatchSuccess, ConfigValidationError>; |
| 51 | |
| 52 | export function resolveConfigPath( |
| 53 | scope: WriteScope, |
| 54 | cwd: string, |
| 55 | homedirOverride?: string, |
| 56 | ): string { |
| 57 | if (scope === 'user') { |
| 58 | const home = homedirOverride ?? homedir(); |
| 59 | return resolve(home, OK_DIR, USER_CONFIG_FILENAME); |
| 60 | } |
| 61 | const absCwd = isAbsolute(cwd) ? cwd : resolve(cwd); |
| 62 | if (scope === 'project-local') { |
| 63 | return resolve(absCwd, OK_DIR, LOCAL_DIR, CONFIG_FILENAME); |
| 64 | } |
| 65 | return resolve(absCwd, OK_DIR, CONFIG_FILENAME); |
| 66 | } |
| 67 | |
| 68 | function err(error: ConfigValidationError): Err<ConfigValidationError> { |
| 69 | return { ok: false, error }; |
no outgoing calls