shell() added pawershell detection

This commit is contained in:
Sebastian Hildebrandt 2025-01-07 16:20:27 +01:00
parent f77172d993
commit c7d4751518

View File

@ -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) {