Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/support/writeReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
if (logFileExists) {
const logFileContent = await readFile(logFile, "utf8");
output += `----------------------------------------------------------- Logfile -----------------------------------------------------------------${EOL}`;
output += logFileContent + EOL + lineBreak;
output += replaceUserPathInStr(logFileContent) + EOL + lineBreak;
}
const resultFile = join(context.extensionPath, "report.txt");
await writeFile(resultFile, output);
Expand All @@ -232,13 +232,19 @@
const strReport = JSON.stringify(report);

// Replacing all home paths (based on OS) with '...' using es6 syntax. Can be replaced with one line using .replaceAll() when we will update the version of ECMAScript to 2021 or higher
const parsedReport = replaceUserPathInStr(strReport);

return JSON.parse(parsedReport);
}

function replaceUserPathInStr(strReport: string) {
let re = new RegExp(process.env.HOME, "g");
if (process.env.windir) {
const reWin = new RegExp("\\\\", "g");
const result = process.env.HOMEPATH.replace(reWin, "\\\\\\\\");
re = new RegExp(result, "g");
const PosixResult = process.env.HOMEPATH.replace(reWin, "/");
re = new RegExp(`(${result}|${PosixResult})`, "g");
}
const parsedReport = strReport.replace(re, "<HOMEPATH>");

return JSON.parse(parsedReport);
return parsedReport;
}