shell() added pawershell detection
This commit is contained in:
parent
f77172d993
commit
c7d4751518
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user