01 · Before and afterThe pattern
// lookup order mirrors the reference tool; a broken source falls through, never crashes
async function getCreds(cfg: DockerConfig, registry: string) {
const helper = cfg.credHelpers?.[registry] ?? cfg.credsStore;
if (helper) {
const fromHelper = await tryHelper(helper, registry); // returns undefined on exit≠0 or non-JSON
if (fromHelper) return fromHelper;
}
return cfg.auths?.[registry] ?? (hasNoAuthConfig(cfg) ? await tryHelper(platformDefault(), registry) : undefined);
}02 · Run it on your appThe check
If your tool reads Docker or cloud credentials, does it pick the same credentials, in the same order, as the official CLI on the same machine?
If the honest answer is no or not sure, this is worth a look before it reaches production.