From 180ac9dfddd0833a606d63df17753d3685939bee Mon Sep 17 00:00:00 2001 From: hopejr Date: Wed, 4 Nov 2020 23:28:50 +1100 Subject: [PATCH] Update index.js Added ability to return pretty name on Linux, or just hostname if the pretty name isn't set. --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 172de44..d3be5d8 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,9 @@ module.exports = function () { return process.env.COMPUTERNAME case 'darwin': return cp.execSync('scutil --get ComputerName').toString().trim() + case 'linux': + const prettyname = cp.execSync('hostnamectl --pretty').toString().trim() + return prettyname === '' ? os.hostname() : prettyname default: return os.hostname() }