fix(striker-ui-api): adjust os list extraction to match new format from tool output

main
Tsu-ba-me 1 year ago
parent 644953135a
commit ce1c1c6475
  1. 12
      striker-ui-api/src/lib/consts/OS_LIST.ts

@ -5,17 +5,19 @@ import SERVER_PATHS from './SERVER_PATHS';
type OSKeyMapToName = Record<string, string>; type OSKeyMapToName = Record<string, string>;
const osList: string[] = execSync( const osList: string[] = execSync(
`${SERVER_PATHS.usr.sbin['striker-parse-os-list'].self} | ${SERVER_PATHS.usr.bin['sed'].self} -E 's/^.*name="os_list_([^"]+).*CDATA[[]([^]]+).*$/\\1,\\2/'`, SERVER_PATHS.usr.sbin['striker-parse-os-list'].self,
{ {
encoding: 'utf-8', encoding: 'utf-8',
timeout: 10000, timeout: 10000,
}, },
).split('\n'); )
.trim()
osList.pop(); .split('\n');
const osKeyMapToName: OSKeyMapToName = osList.reduce((map, csv) => { const osKeyMapToName: OSKeyMapToName = osList.reduce((map, csv) => {
const [osKey, osName] = csv.split(',', 2); const [osKey, osName] = csv
.replace(/^key=([^\s]+),name=['"](.*)['"]$/, '$1,$2')
.split(',', 2);
map[osKey] = osName; map[osKey] = osName;

Loading…
Cancel
Save