-
9,082
+
9,183
Lines of code
diff --git a/lib/osinfo.js b/lib/osinfo.js
index 366a7c3..4f0b653 100644
--- a/lib/osinfo.js
+++ b/lib/osinfo.js
@@ -410,11 +410,8 @@ function versions(callback) {
functionProcessed();
});
if (_darwin) {
- const cmdLineToolsExists = fs.existsSync('/Library/Developer/CommandLineTools/usr/bin/');
- const xcodeAppExists = fs.existsSync('/Applications/Xcode.app/Contents/Developer/Tools');
- const xcodeExists = fs.existsSync('/Library/Developer/Xcode/');
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/git');
- if (cmdLineToolsExists || xcodeExists || gitHomebrewExists || xcodeAppExists) {
+ if (util.darwinXcodeExists() || gitHomebrewExists) {
exec('git --version', function (error, stdout) {
if (!error) {
let git = stdout.toString().split('\n')[0] || '';
@@ -616,25 +613,29 @@ function versions(callback) {
functionProcessed();
});
}
- exec('gcc -dumpversion', function (error, stdout) {
- if (!error) {
- result.gcc = stdout.toString().split('\n')[0].trim() || '';
- }
- if (result.gcc.indexOf('.') > -1) {
- functionProcessed();
- } else {
- exec('gcc --version', function (error, stdout) {
- if (!error) {
- const gcc = stdout.toString().split('\n')[0].trim();
- if (gcc.indexOf('gcc') > -1 && gcc.indexOf(')') > -1) {
- const parts = gcc.split(')');
- result.gcc = parts[1].trim() || result.gcc;
- }
- }
+ if ((_darwin && util.darwinXcodeExists()) || !_darwin) {
+ exec('gcc -dumpversion', function (error, stdout) {
+ if (!error) {
+ result.gcc = stdout.toString().split('\n')[0].trim() || '';
+ }
+ if (result.gcc.indexOf('.') > -1) {
functionProcessed();
- });
- }
- });
+ } else {
+ exec('gcc --version', function (error, stdout) {
+ if (!error) {
+ const gcc = stdout.toString().split('\n')[0].trim();
+ if (gcc.indexOf('gcc') > -1 && gcc.indexOf(')') > -1) {
+ const parts = gcc.split(')');
+ result.gcc = parts[1].trim() || result.gcc;
+ }
+ }
+ functionProcessed();
+ });
+ }
+ });
+ } else {
+ functionProcessed();
+ }
exec(util.getVboxmanage() + ' -v 2>&1', function (error, stdout) {
if (!error) {
const vbox = stdout.toString().split('\n')[0] || '';
diff --git a/lib/util.js b/lib/util.js
index 56646db..8800433 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -386,6 +386,13 @@ function execWin(cmd, opts, callback) {
});
}
+function darwinXcodeExists() {
+ const cmdLineToolsExists = fs.existsSync('/Library/Developer/CommandLineTools/usr/bin/');
+ const xcodeAppExists = fs.existsSync('/Applications/Xcode.app/Contents/Developer/Tools');
+ const xcodeExists = fs.existsSync('/Library/Developer/Xcode/');
+ return (cmdLineToolsExists || xcodeExists || xcodeAppExists);
+}
+
function nanoSeconds() {
const time = process.hrtime();
if (!Array.isArray(time) || time.length !== 2) {
@@ -423,6 +430,7 @@ exports.parseHead = parseHead;
exports.findObjectByKey = findObjectByKey;
exports.getWmic = getWmic;
exports.wmic = wmic;
+exports.darwinXcodeExists = darwinXcodeExists;
exports.getVboxmanage = getVboxmanage;
exports.powerShell = powerShell;
exports.nanoSeconds = nanoSeconds;