From ab0b5e379f08abd95114e770603fae60af3b2c23 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sat, 19 Dec 2020 20:38:47 +0100 Subject: [PATCH] versions() mac OS python test command line tools --- lib/osinfo.js | 54 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/lib/osinfo.js b/lib/osinfo.js index 734c318..22b0c82 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -739,22 +739,52 @@ function versions(apps, callback) { }); } if ({}.hasOwnProperty.call(appsObj.versions, 'python')) { - exec('python -V 2>&1', function (error, stdout) { - if (!error) { - const python = stdout.toString().split('\n')[0] || ''; - appsObj.versions.python = python.toLowerCase().replace('python', '').trim(); + if (_darwin) { + const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/python'); + if (util.darwinXcodeExists() || gitHomebrewExists) { + exec('python -V 2>&1', function (error, stdout) { + if (!error) { + const python = stdout.toString().split('\n')[0] || ''; + appsObj.versions.python = python.toLowerCase().replace('python', '').trim(); + } + functionProcessed(); + }); + } else { + functionProcessed(); } - functionProcessed(); - }); + } else { + exec('python -V 2>&1', function (error, stdout) { + if (!error) { + const python = stdout.toString().split('\n')[0] || ''; + appsObj.versions.python = python.toLowerCase().replace('python', '').trim(); + } + functionProcessed(); + }); + } } if ({}.hasOwnProperty.call(appsObj.versions, 'python3')) { - exec('python3 -V 2>&1', function (error, stdout) { - if (!error) { - const python = stdout.toString().split('\n')[0] || ''; - appsObj.versions.python3 = python.toLowerCase().replace('python', '').trim(); + if (_darwin) { + const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/python3'); + if (util.darwinXcodeExists() || gitHomebrewExists) { + exec('python3 -V 2>&1', function (error, stdout) { + if (!error) { + const python = stdout.toString().split('\n')[0] || ''; + appsObj.versions.python3 = python.toLowerCase().replace('python', '').trim(); + } + functionProcessed(); + }); + } else { + functionProcessed(); } - functionProcessed(); - }); + } else { + exec('python3 -V 2>&1', function (error, stdout) { + if (!error) { + const python = stdout.toString().split('\n')[0] || ''; + appsObj.versions.python3 = python.toLowerCase().replace('python', '').trim(); + } + functionProcessed(); + }); + } } if ({}.hasOwnProperty.call(appsObj.versions, 'pip')) { exec('pip -V 2>&1', function (error, stdout) {