diff --git a/lib/system.js b/lib/system.js index 06c41d3e..a4f9677b 100644 --- a/lib/system.js +++ b/lib/system.js @@ -473,11 +473,11 @@ function baseboard(callback) { workload ).then((data) => { let lines = data.results[0] ? data.results[0].toString().split('\n') : ['']; - result.manufacturer = util.getValue(lines, 'Manufacturer'); - result.model = util.getValue(lines, 'Product Name'); - result.version = util.getValue(lines, 'Version'); - result.serial = util.getValue(lines, 'Serial Number'); - result.assetTag = util.getValue(lines, 'Asset Tag'); + result.manufacturer = cleanDefaults(util.getValue(lines, 'Manufacturer')); + result.model = cleanDefaults(util.getValue(lines, 'Product Name')); + result.version = cleanDefaults(util.getValue(lines, 'Version')); + result.serial = cleanDefaults(util.getValue(lines, 'Serial Number')); + result.assetTag = cleanDefaults(util.getValue(lines, 'Asset Tag')); // Non-Root values const cmd = `echo -n "board_asset_tag: "; cat /sys/devices/virtual/dmi/id/board_asset_tag 2>/dev/null; echo; echo -n "board_name: "; cat /sys/devices/virtual/dmi/id/board_name 2>/dev/null; echo; @@ -486,16 +486,14 @@ function baseboard(callback) { echo -n "board_version: "; cat /sys/devices/virtual/dmi/id/board_version 2>/dev/null; echo;`; try { lines = execSync(cmd, util.execOptsLinux).toString().split('\n'); - result.manufacturer = !result.manufacturer ? util.getValue(lines, 'board_vendor') : result.manufacturer; - result.model = !result.model ? util.getValue(lines, 'board_name') : result.model; - result.version = !result.version ? util.getValue(lines, 'board_version') : result.version; - result.serial = !result.serial ? util.getValue(lines, 'board_serial') : result.serial; - result.assetTag = !result.assetTag ? util.getValue(lines, 'board_asset_tag') : result.assetTag; + result.manufacturer = cleanDefaults(!result.manufacturer ? util.getValue(lines, 'board_vendor') : result.manufacturer); + result.model = cleanDefaults(!result.model ? util.getValue(lines, 'board_name') : result.model); + result.version = cleanDefaults(!result.version ? util.getValue(lines, 'board_version') : result.version); + result.serial = cleanDefaults(!result.serial ? util.getValue(lines, 'board_serial') : result.serial); + result.assetTag = cleanDefaults(!result.assetTag ? util.getValue(lines, 'board_asset_tag') : result.assetTag); } catch (e) { util.noop(); } - if (result.serial.toLowerCase().indexOf('o.e.m.') !== -1) { result.serial = '-'; } - if (result.assetTag.toLowerCase().indexOf('o.e.m.') !== -1) { result.assetTag = '-'; } // mem lines = data.results[1] ? data.results[1].toString().split('\n') : ['']; @@ -675,16 +673,12 @@ function chassis(callback) { echo -n "chassis_version: "; cat /sys/devices/virtual/dmi/id/chassis_version 2>/dev/null; echo;`; exec(cmd, function (error, stdout) { let lines = stdout.toString().split('\n'); - result.manufacturer = util.getValue(lines, 'chassis_vendor'); + result.manufacturer = cleanDefaults(util.getValue(lines, 'chassis_vendor')); const ctype = parseInt(util.getValue(lines, 'chassis_type').replace(/\D/g, '')); - result.type = (ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype - 1] : ''; - result.version = util.getValue(lines, 'chassis_version'); - result.serial = util.getValue(lines, 'chassis_serial'); - result.assetTag = util.getValue(lines, 'chassis_asset_tag'); - if (result.manufacturer.toLowerCase().indexOf('o.e.m.') !== -1) { result.manufacturer = '-'; } - if (result.version.toLowerCase().indexOf('o.e.m.') !== -1) { result.version = '-'; } - if (result.serial.toLowerCase().indexOf('o.e.m.') !== -1) { result.serial = '-'; } - if (result.assetTag.toLowerCase().indexOf('o.e.m.') !== -1) { result.assetTag = '-'; } + result.type = cleanDefaults((ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype - 1] : ''); + result.version = cleanDefaults(util.getValue(lines, 'chassis_version')); + result.serial = cleanDefaults(util.getValue(lines, 'chassis_serial')); + result.assetTag = cleanDefaults(util.getValue(lines, 'chassis_asset_tag')); if (callback) { callback(result); } resolve(result);