Skip to content

Commit

Permalink
0.2.0
Browse files Browse the repository at this point in the history
Added wmic binary for Centos/RedHat & Ubuntu/Debian (all only x64)
  • Loading branch information
NAlexandrov committed Aug 27, 2015
1 parent 8ae88a3 commit ca6166f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
Binary file added bin/wmic_centos_x64
Binary file not shown.
Binary file added bin/wmic_ubuntu_x64
Binary file not shown.
24 changes: 22 additions & 2 deletions lib/wmic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

var spawn = require('child_process').spawn;
var getos = require('getos');
var path = require('path');
var spawn = require('child_process').spawn;

var getNamespace = require('./namespace.js');
var getUsername = require('./username.js');
Expand All @@ -13,6 +14,7 @@ var parse = require('./parse.js');
* @returns {wmic}
*/
var wmic = function (options) {
this.options = options;
this.host = options.host;
this.username = getUsername(options.username);
this.password = options.password;
Expand Down Expand Up @@ -99,6 +101,8 @@ wmic.prototype._getArgsForWindows = function () {
* @returns {wmic}
*/
wmic.prototype.query = function (wql, namespace, callback) {
var self = this;

this.wql = wql;

if (typeof namespace === 'string') {
Expand All @@ -108,7 +112,23 @@ wmic.prototype.query = function (wql, namespace, callback) {
}

if (typeof callback === 'function') {
this._exec(callback);
if (!this.options.wmic && process.platform === 'linux' && process.arch === 'x64') {
getos(function (err, os) {
if (err) {
callback(err);
}

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) {
self.wmic = 'bin/wmic_centos_x64';
}

self._exec(callback);
});
} else {
this._exec(callback);
}
}

return this;
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wmi-client",
"version": "0.1.5",
"version": "0.2.0",
"description": "Wrapper around the WMI client. Linux and Windows WMI clients are supported.",
"main": "index.js",
"scripts": {
Expand All @@ -19,5 +19,8 @@
"bugs": {
"url": "https://github.com/R-Vision/wmi-client/issues"
},
"homepage": "https://github.com/R-Vision/wmi-client"
"homepage": "https://github.com/R-Vision/wmi-client",
"dependencies": {
"getos": "^2.4.0"
}
}

0 comments on commit ca6166f

Please sign in to comment.