Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kentcdodds/lineage

src/settings.ts

30 lines · 786 B · TypeScript
import { getRepoSettings, ingestSummary, setRepoSettings } from './storage.ts'

/**
 * Read or update the tracked GitHub repository stored in package storage.
 * Pass fields to persist a new owner/repo/branch without republishing.
 *
 * @param input - Optional owner, repo, and branch to store
 * @returns Current settings plus ingest summary
 *
 * @example
 * import settings from 'kody:@kentcdodds/lineage/settings'
 *
 * const current = await settings()
 */
export default async function settings(
	input: {
		owner?: string
		repo?: string
		branch?: string
	} = {},
) {
	const hasUpdate = Boolean(input.owner || input.repo || input.branch)
	const repo = hasUpdate
		? await setRepoSettings(input)
		: await getRepoSettings()
	return {
		repo,
		ingest: await ingestSummary(),
	}
}