MCPcopy Create free account
hub / github.com/cloudflare/computer / configGetWith

Function configGetWith

packages/computer/src/git/plumbing.ts:229–247  ·  view source on GitHub ↗
(
  opts: ConfigGetWithDeps,
)

Source from the content-addressed store, hash-verified

227 * --get` which exits 1 with no output for an unknown key.
228 */
229export async function configGetWith(
230 opts: ConfigGetWithDeps,
231): Promise<string | string[] | undefined> {
232 const dir = opts.dir ?? "/";
233 try {
234 if (opts.all) {
235 const values = await opts.git.getConfigAll({ fs: opts.fs, dir, path: opts.path });
236 return values.map((v) => String(v));
237 }
238 const value = await opts.git.getConfig({ fs: opts.fs, dir, path: opts.path });
239 if (value === undefined || value === null) return undefined;
240 return String(value);
241 } catch (cause) {
242 if (isNotARepositoryCause(cause)) throw new NotARepositoryError(dir, { cause });
243 throw new GitError("ECONFIGFAIL", `git config failed: ${errorMessage(cause)}`, {
244 cause,
245 });
246 }
247}
248
249export interface GitConfigSetOptions {
250 dir?: string;

Callers 2

configGetFunction · 0.85
plumbing.test.tsFile · 0.85

Calls 4

isNotARepositoryCauseFunction · 0.85
getConfigAllMethod · 0.80
errorMessageFunction · 0.70
getConfigMethod · 0.65

Tested by

no test coverage detected