mirror of https://github.com/garrytan/gstack.git
fix(browse): duplicate config keys read last-wins, matching gstack-config
readGstackConfigYamlKey took the FIRST match while gstack-config's get takes the LAST — a duplicated pair_agent or telemetry line made the two consent surfaces disagree about what the user chose.
This commit is contained in:
parent
8049d0b4ac
commit
25a512c7e0
|
|
@ -180,8 +180,10 @@ export function readGstackConfigYamlKey(key: string): string | null {
|
||||||
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
try {
|
try {
|
||||||
const yaml = fs.readFileSync(path.join(resolveGstackHome(), 'config.yaml'), 'utf-8');
|
const yaml = fs.readFileSync(path.join(resolveGstackHome(), 'config.yaml'), 'utf-8');
|
||||||
const m = yaml.match(new RegExp(`^\\s*${escaped}\\s*:\\s*['"]?([^'"#\\n]*?)['"]?\\s*(?:#.*)?$`, 'm'));
|
// Last match wins: bin/gstack-config's `get` reads duplicates with
|
||||||
return m ? m[1] : null;
|
// `tail -1`, and both surfaces must agree on the same line.
|
||||||
|
const all = [...yaml.matchAll(new RegExp(`^\\s*${escaped}\\s*:\\s*['"]?([^'"#\\n]*?)['"]?\\s*(?:#.*)?$`, 'gm'))];
|
||||||
|
return all.length > 0 ? all[all.length - 1][1] : null;
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue