| 160 | * Remove secret metadata from the config file. |
| 161 | */ |
| 162 | export const removeSecretFromConfig = ( |
| 163 | path: string, |
| 164 | secretId: string, |
| 165 | ): Effect.Effect<void, PlatformError, FileSystem.FileSystem> => |
| 166 | Effect.gen(function* () { |
| 167 | const fs = yield* FileSystem.FileSystem; |
| 168 | |
| 169 | const exists = yield* fs.exists(path); |
| 170 | if (!exists) return; |
| 171 | |
| 172 | let text = yield* fs.readFileString(path); |
| 173 | const edits = jsonc.modify(text, ["secrets", secretId], undefined, { |
| 174 | formattingOptions: FORMATTING, |
| 175 | }); |
| 176 | text = jsonc.applyEdits(text, edits); |
| 177 | |
| 178 | yield* fs.writeFileString(path, text); |
| 179 | }); |