From 176c4e9afd6df8e823d98c5ed61f095958cbece2 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 1 Jul 2019 17:55:27 +0200 Subject: [PATCH] versions() gcc fix macOS --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 4 ++-- lib/osinfo.js | 45 +++++++++++++++++++++++---------------------- lib/util.js | 8 ++++++++ 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9589fa9..eb83ad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.13.1 | 2019-07-01 | `versions()` gcc fix macos | | 4.13.0 | 2019-07-01 | `networkConnections()` added PID and process | | 4.12.2 | 2019-06-24 | `system()` added Raspberry PI 4 detection | | 4.12.1 | 2019-06-24 | `networkInterface()` virtual interfaces macos, `networkInterfaceDefault()` | diff --git a/docs/history.html b/docs/history.html index 95facc0..cf0025d 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.13.1 + 2019-07-01 + versions() gcc fix macos + 4.13.0 2019-07-01 diff --git a/docs/index.html b/docs/index.html index d36a225..93f51e9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.13.0
+
Current Version: 4.13.1
@@ -191,7 +191,7 @@
-
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;