MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / serializeCredentials

Function serializeCredentials

src/lib/credentials.ts:70–90  ·  view source on GitHub ↗
(file: CredentialsFile)

Source from the content-addressed store, hash-verified

68}
69
70export function serializeCredentials(file: CredentialsFile): string {
71 const orderedSections = Object.keys(file).sort((a, b) => {
72 if (a === DEFAULT_PROFILE) return -1;
73 if (b === DEFAULT_PROFILE) return 1;
74 return a.localeCompare(b);
75 });
76 const lines: string[] = [];
77 for (const section of orderedSections) {
78 const entry = file[section];
79 if (!entry) continue;
80 lines.push(`[${section}]`);
81 const fields = Object.keys(entry).sort() as Array<keyof ProfileEntry>;
82 for (const field of fields) {
83 const value = entry[field];
84 if (value === undefined || value === '') continue;
85 lines.push(`${FIELD_TO_FILE_KEY[field]} = ${value}`);
86 }
87 lines.push('');
88 }
89 return lines.join('\n').trimEnd() + '\n';
90}
91
92export function readCredentialsFile(options: CredentialsOptions = {}): CredentialsFile {
93 const path = resolvePath(options);

Callers 2

writeCredentialsAtomicFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected