From 38c9ed8c4fb48c27aca027b28a883f34ed3def76 Mon Sep 17 00:00:00 2001 From: Li Wang Date: Fri, 17 Dec 2021 17:36:23 +0800 Subject: [PATCH] 1) fix bug that can't run on CentOS; 2) support a value with multi lines --- lib/wmic.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/wmic.js b/lib/wmic.js index c0b98b7..1a1e163 100644 --- a/lib/wmic.js +++ b/lib/wmic.js @@ -146,7 +146,7 @@ wmic.prototype.query = function (wql, namespace, callback) { if (os.dist.search(/ubuntu/i) === 0 || os.dist.search(/debian/i) === 0) { self.wmic = 'bin/wmic_ubuntu_x64'; - } else if (os.dist.search(/centos/i) === 0 || os.dist.search(/redhat/i) === 0) { + } else if (os.dist.search(/centos/i) === 0 || os.dist.search(/rhel/i) === 0) { self.wmic = 'bin/wmic_centos_x64'; } @@ -182,11 +182,12 @@ wmic.prototype._exec = function (callback) { var result = []; var keys = []; + var lines = ""; rl.on('line', function (line) { if (line.length === 0 || line.indexOf('CLASS: ') === 0) return; - var item = line.toString().trim().split(self.parserOptions.delimiter); + var item = (lines + line).toString().trim().split(self.parserOptions.delimiter); if (self.parserOptions.trim === true) { item = item.map(function (v) { @@ -208,6 +209,9 @@ wmic.prototype._exec = function (callback) { }); result.push(obj); + lines = ""; + } else { + lines = lines + "\r\n" + line; } });