uuid() object - os specific uuid
This commit is contained in:
+8
-5
@@ -505,14 +505,16 @@ function uuid(callback) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
|
||||
let result = '';
|
||||
let result = {
|
||||
os: ''
|
||||
};
|
||||
let parts;
|
||||
|
||||
if (_darwin) {
|
||||
exec('ioreg -rd1 -c IOPlatformExpertDevice | grep IOPlatformUUID', function (error, stdout) {
|
||||
if (!error) {
|
||||
parts = stdout.toString().split('\n')[0].replace(/"/g, '').split('=');
|
||||
result = parts.length > 1 ? parts[1].trim().toLowerCase() : '';
|
||||
result.os = parts.length > 1 ? parts[1].trim().toLowerCase() : '';
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
@@ -523,7 +525,7 @@ function uuid(callback) {
|
||||
if (_linux) {
|
||||
exec('( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :', function (error, stdout) {
|
||||
if (!error) {
|
||||
result = stdout.toString().split('\n')[0].trim().toLowerCase();
|
||||
result.os = stdout.toString().split('\n')[0].trim().toLowerCase();
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
@@ -534,7 +536,7 @@ function uuid(callback) {
|
||||
if (_freebsd || _openbsd) {
|
||||
exec('kenv -q smbios.system.uuid', function (error, stdout) {
|
||||
if (!error) {
|
||||
result = stdout.toString().split('\n')[0].trim().toLowerCase();
|
||||
result.os = stdout.toString().split('\n')[0].trim().toLowerCase();
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
@@ -545,7 +547,8 @@ function uuid(callback) {
|
||||
if (_windows) {
|
||||
exec('%windir%\\System32\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid', util.execOptsWin, function (error, stdout) {
|
||||
if (!error) {
|
||||
result = stdout.toString().split('\n')[0].split('REG_SZ')[1].replace(/\r+|\n+|\s+/ig, '').toLowerCase();
|
||||
parts = stdout.toString().split('\n\r')[0].split('REG_SZ');
|
||||
result.os = parts.length > 1 ? parts[1].replace(/\r+|\n+|\s+/ig, '').toLowerCase() : '';
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
|
||||
Reference in New Issue
Block a user