From c7d4751518643d3705a3369af330292bd3096ea6 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 7 Jan 2025 16:20:27 +0100 Subject: [PATCH] shell() added pawershell detection --- lib/osinfo.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/osinfo.js b/lib/osinfo.js index 3d19623..f2252ff 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -1120,7 +1120,28 @@ function shell(callback) { return new Promise((resolve) => { process.nextTick(() => { if (_windows) { - resolve('cmd'); + try { + const result = 'CMD'; + util.powerShell('$PSVersionTable').then(stdout => { + if (stdout) { + const lines = stdout.toString().toLowerCase().split('\n').map(line => line.replace(/ +/g, ' ').replace(/ +/g, ':')); + const ps = getValue(lines, 'psversion'); + let result = 'CMD'; + if (ps) { + result = `PowerShell ${ps.split('.')[0] + (ps.split('.')[1] ? '.' + ps.split('.')[1] : '')}`; + } + }; + if (callback) { + callback(result); + } + resolve(result); + }); + } catch { + if (callback) { + callback(result); + } + resolve(result); + } } else { let result = ''; exec('echo $SHELL', function (error, stdout) {