versions() bug fix macOS detection

This commit is contained in:
Sebastian Hildebrandt
2018-12-29 13:28:40 +01:00
parent 866ca78a7f
commit 02e527f808
3 changed files with 16 additions and 31 deletions
+15 -29
View File
@@ -367,35 +367,21 @@ function versions(callback) {
functionProcessed();
});
if (_darwin) {
let filename = '/Library/Developer/CommandLineTools/';
fs.access(filename, fs.constants.F_OK, (err) => {
if (!err) {
exec('git --version', function (error, stdout) {
if (!error) {
let git = stdout.toString().split('\n')[0] || '';
git = (git.toLowerCase().split('version')[1] || '').trim();
result.git = (git.split(' ')[0] || '').trim();
}
functionProcessed();
});
} else {
let filename = '/usr/local/Cellar/git';
fs.access(filename, fs.constants.F_OK, (err) => {
if (!err) {
exec('git --version', function (error, stdout) {
if (!error) {
let git = stdout.toString().split('\n')[0] || '';
git = (git.toLowerCase().split('version')[1] || '').trim();
result.git = (git.split(' ')[0] || '').trim();
}
functionProcessed();
});
} else {
functionProcessed();
}
});
}
});
const cmdLineToolsExists = fs.existsSync('/Library/Developer/CommandLineTools/');
const xcodeExists = fs.existsSync('/Library/Developer/Xcode/');
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/git');
if (cmdLineToolsExists || xcodeExists || gitHomebrewExists) {
exec('git --version', function (error, stdout) {
if (!error) {
let git = stdout.toString().split('\n')[0] || '';
git = (git.toLowerCase().split('version')[1] || '').trim();
result.git = (git.split(' ')[0] || '').trim();
}
functionProcessed();
});
} else {
functionProcessed();
}
} else {
exec('git --version', function (error, stdout) {
if (!error) {