From ce1c1c6475cc31091f045d65af4a30bc364723bd Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Sun, 20 Aug 2023 19:44:33 -0400 Subject: [PATCH] fix(striker-ui-api): adjust os list extraction to match new format from tool output --- striker-ui-api/src/lib/consts/OS_LIST.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/striker-ui-api/src/lib/consts/OS_LIST.ts b/striker-ui-api/src/lib/consts/OS_LIST.ts index 6cea3615..1ff49d25 100644 --- a/striker-ui-api/src/lib/consts/OS_LIST.ts +++ b/striker-ui-api/src/lib/consts/OS_LIST.ts @@ -5,17 +5,19 @@ import SERVER_PATHS from './SERVER_PATHS'; type OSKeyMapToName = Record; 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', timeout: 10000, }, -).split('\n'); - -osList.pop(); +) + .trim() + .split('\n'); 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;