diff --git a/.travis.yml b/.travis.yml index e3758de..3856fc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ language: node_js +os: + - linux + - osx node_js: - stable - "0.12" diff --git a/lib/linux.js b/lib/linux.js index 5b30418..799d7ac 100644 --- a/lib/linux.js +++ b/lib/linux.js @@ -1,11 +1,11 @@ -var exec = require('child_process').exec; +var execFile = require('child_process').execFile; module.exports = function (iface, callback) { - exec("cat /sys/class/net/" + iface + "/address", function (err, out) { + execFile("cat", ["/sys/class/net/" + iface + "/address"], function (err, out) { if (err) { callback(err, null); return; } callback(null, out.trim().toLowerCase()); }); -}; +}; \ No newline at end of file diff --git a/lib/macosx.js b/lib/macosx.js deleted file mode 100644 index 904ed2d..0000000 --- a/lib/macosx.js +++ /dev/null @@ -1,16 +0,0 @@ -var exec = require('child_process').exec; - -module.exports = function (iface, callback) { - exec("networksetup -getmacaddress " + iface, function (err, out) { - if (err) { - callback(err, null); - return; - } - var match = /[a-f0-9]{2}(:[a-f0-9]{2}){5}/.exec(out.toLowerCase()); - if (!match) { - callback("did not find a mac address", null); - return; - } - callback(null, match[0]); - }); -}; diff --git a/lib/unix.js b/lib/unix.js index d5ca59a..f18ab14 100644 --- a/lib/unix.js +++ b/lib/unix.js @@ -1,7 +1,7 @@ -var exec = require('child_process').exec; +var execFile = require('child_process').execFile; module.exports = function (iface, callback) { - exec("ifconfig " + iface, function (err, out) { + execFile("ifconfig", [iface], function (err, out) { if (err) { callback(err, null); return; diff --git a/lib/windows.js b/lib/windows.js index 87b1b6b..9f0263d 100644 --- a/lib/windows.js +++ b/lib/windows.js @@ -1,4 +1,4 @@ -var exec = require('child_process').exec; +var execFile = require('child_process').execFile; var regexRegex = /[-\/\\^$*+?.()|[\]{}]/g; @@ -7,7 +7,7 @@ function escape(string) { } module.exports = function (iface, callback) { - exec("ipconfig /all", function (err, out) { + execFile("ipconfig", ["/all"], function (err, out) { if (err) { callback(err, null); return; diff --git a/package.json b/package.json index ba32f6f..515fb3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "macaddress", - "version": "0.2.9", + "version": "0.2.10", "description": "Get the MAC addresses (hardware addresses) of the hosts network interfaces.", "main": "index.js", "scripts": {