Refactor Windows installer progress parsing to improve file name handling

- Updated the parsing logic in `parseWindowsInstallerProgress` to extract the file name from the copy file path, ensuring only the file name is displayed in progress messages.
- Enhanced readability by renaming the variable from `relativePath` to `fileName` and added logic to handle paths correctly.
This commit is contained in:
Tom Butcher 2026-08-09 13:40:02 +01:00
parent 2068b7470b
commit df1228ffa6

View File

@ -45,7 +45,10 @@ const parseWindowsInstallerProgress = (output) => {
const copyFile = line.match(/^installer:COPY_FILE:(\d+):(.*)$/)
if (copyFile) {
const fileBytes = Number.parseInt(copyFile[1], 10)
const relativePath = copyFile[2].trim()
var fileName = copyFile[2].trim()
if (fileName.includes('\\')) {
fileName = fileName.split('\\').pop()
}
if (Number.isFinite(fileBytes)) {
copiedBytes += fileBytes
@ -57,8 +60,8 @@ const parseWindowsInstallerProgress = (output) => {
}
}
if (relativePath) {
message = `Copying ${relativePath} (${formatBytes(fileBytes)})`
if (fileName) {
message = `Copying ${fileName} (${formatBytes(fileBytes)})`
}
}
} else if (