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;