Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for Windows 10 WSL #11

Merged
merged 1 commit into from Jun 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions index.js
Expand Up @@ -31,8 +31,21 @@ function parallel(tasks, done) {
}

lib.networkInterfaces = function () {
var ifaces = os.networkInterfaces();
var allAddresses = {};

try {
var ifaces = os.networkInterfaces();
} catch (e) {
// At October 2016 WSL does not support os.networkInterfaces() and throws
// Return empty object as if no interfaces were found
// https://github.com/Microsoft/BashOnWindows/issues/468
if (e.syscall === 'uv_interface_addresses') {
return allAddresses;
} else {
throw e;
};
};

Object.keys(ifaces).forEach(function (iface) {
var addresses = {};
var hasAddresses = false;
Expand Down Expand Up @@ -67,7 +80,7 @@ switch (os.platform()) {
case 'sunos':
_getMacAddress = require('./lib/unix.js');
break;

default:
console.warn("node-macaddress: Unkown os.platform(), defaulting to `unix'.");
_getMacAddress = require('./lib/unix.js');
Expand Down