description and source-codegetMac = function (opts, next) {
var command, data, extractMac, ref;
ref = extractOptsAndCallback(opts, next), opts = ref[0], next = ref[1];
data = opts.data;
if (data == null) {
data = null;
}
command = isWindows ? "getmac" : "ifconfig -a || ip link";
extractMac = function(data, next) {
var err, isZero, macAddress, match, result;
result = null;
while (match = macRegex.exec(data)) {
macAddress = match[0];
isZero = zeroRegex.test(macAddress);
if (isZero === false) {
if (result == null) {
result = macAddress;
}
}
}
if (result === null) {
err = new Error('could not determine the mac address from:\n' + data);
return next(err);
}
return next(null, result);
};
if (data) {
return extractMac(data, next);
} else {
return exec(command, function(err, stdout, stderr) {
if (err) {
return next(err);
}
return extractMac(stdout, next);
});
}
}