Skip to content

Commit 58d6cdf

Browse files
committed
fix(parsing): détection dynamique de la colonne version pour am/appman -f
1 parent 98b4d54 commit 58d6cdf

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

main.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,16 +889,26 @@ ipcMain.handle('list-apps-detailed', async () => {
889889
/^TOTAL/i,
890890
/^\*has/i
891891
];
892+
let versionColIdx = 2; // par défaut, colonne 3 (0-based)
893+
let headerParsed = false;
892894
for (const raw of lines) {
893895
let line = raw.trim();
894896
if (!line) continue;
897+
if (line.startsWith('APPNAME') || line.startsWith('- APPNAME')) {
898+
// Détecter la colonne version dynamiquement
899+
const headerCols = line.replace(/^- /, '').split('|').map(s => s.trim());
900+
versionColIdx = headerCols.findIndex(col => col.toLowerCase().startsWith('version'));
901+
headerParsed = true;
902+
continue;
903+
}
904+
if (line.startsWith('-------')) continue; // ignorer la ligne de séparation
895905
if (line.startsWith('\u25c6')) line = line.slice(1).trim();
896906
if (!line) continue;
897-
// Try to parse "name | version | type | size" separated by | if present
907+
// Try to parse "name | ... | version | ..." separated by |
898908
if (line.includes('|')) {
899909
const cols = line.split('|').map(s => s.trim()).filter(Boolean);
900910
const name = cols[0] ? cols[0].split(/\s+/)[0].trim() : null;
901-
const version = cols[1] ? cols[1] : null;
911+
const version = (typeof versionColIdx === 'number' && versionColIdx >= 0 && versionColIdx < cols.length) ? cols[versionColIdx] : null;
902912
if (name && !ignoreNamePatterns.some(re => re.test(name))) {
903913
installedSet.add(name);
904914
if (version) installedDesc.set(name, version);

0 commit comments

Comments
 (0)