MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / parseOptions

Function parseOptions

scripts/web-env/index.ts:36–61  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

34 continue;
35 }
36 return sensitive;
37 }
38}
39
40function normalizeFileValue(value: string): string {
41 const trailingNewlineLength = value.endsWith('\r\n') ? 2 : value.endsWith('\n') ? 1 : 0;
42 if (trailingNewlineLength === 0) return value;
43 const valueWithoutTrailingNewline = value.slice(0, -trailingNewlineLength);
44 return /[\r\n]/.test(valueWithoutTrailingNewline) ? value : valueWithoutTrailingNewline;
45}
46
47async function collectValues(
48 options: SetOptions,
49 environments: readonly Environment[]
50): Promise<Partial<Record<Environment, string>>> {
51 const values: Partial<Record<Environment, string>> = {};
52 for (const environment of environments) {
53 const file = options.valueFiles[environment];
54 if (file) {
55 const value = stripSurroundingQuotes(
56 normalizeFileValue(readFileSync(path.resolve(file), 'utf8'))
57 );
58 if (!value) throw new Error(`${environment} value file cannot be empty.`);
59 values[environment] = value;
60 continue;
61 }
62
63 while (!values[environment]) {
64 const value = stripSurroundingQuotes(await readSecret(`${environment} value: `));

Callers 1

mainFunction · 0.85

Calls 1

usageFunction · 0.70

Tested by

no test coverage detected