Skip to content

Commit da5d3b6

Browse files
feat(systeminfo): include Git hash and branch in system information log
1 parent 03e4eef commit da5d3b6

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

js/systeminformation.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
const os = require("node:os");
2+
const { execFileSync } = require("node:child_process");
23
const si = require("systeminformation");
34
// needed with relative path because logSystemInformation is called in an own process in app.js:
45
const mmVersion = require("../package").version;
56
const Log = require("./logger");
67

8+
let mmGitHash = "";
9+
let mmGitBranch = "";
10+
try {
11+
mmGitHash = execFileSync("git", ["rev-parse", "--short", "HEAD"], { encoding: "utf8" }).trim();
12+
mmGitBranch = execFileSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { encoding: "utf8" }).trim();
13+
} catch {
14+
// not a git repo or git not available
15+
}
16+
717
const logSystemInformation = async () => {
818
try {
919
const system = await si.system();
@@ -17,7 +27,8 @@ const logSystemInformation = async () => {
1727

1828
let systemDataString = [
1929
"\n#### System Information ####",
20-
`- SYSTEM: manufacturer: ${system.manufacturer}; model: ${system.model}; virtual: ${system.virtual}; MM: v${mmVersion}`,
30+
`- MM: version: v${mmVersion}${mmGitHash ? `; git: ${mmGitHash}` : ""}${mmGitBranch ? `; branch: ${mmGitBranch}` : ""}`,
31+
`- SYSTEM: manufacturer: ${system.manufacturer}; model: ${system.model}; virtual: ${system.virtual}`,
2132
`- OS: platform: ${osInfo.platform}; distro: ${osInfo.distro}; release: ${osInfo.release}; arch: ${osInfo.arch}; kernel: ${versions.kernel}`,
2233
`- VERSIONS: electron: ${process.env.ELECTRON_VERSION}; used node: ${process.env.USED_NODE_VERSION}; installed node: ${installedNodeVersion}; npm: ${versions.npm}; pm2: ${versions.pm2}`,
2334
`- ENV: XDG_SESSION_TYPE: ${process.env.XDG_SESSION_TYPE}; MM_CONFIG_FILE: ${process.env.MM_CONFIG_FILE}`,

0 commit comments

Comments
 (0)