File tree 1 file changed +15
-2
lines changed 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,21 @@ function parallel(tasks, done) {
31
31
}
32
32
33
33
lib . networkInterfaces = function ( ) {
34
- var ifaces = os . networkInterfaces ( ) ;
35
34
var allAddresses = { } ;
35
+
36
+ try {
37
+ var ifaces = os . networkInterfaces ( ) ;
38
+ } catch ( e ) {
39
+ // At October 2016 WSL does not support os.networkInterfaces() and throws
40
+ // Return empty object as if no interfaces were found
41
+ // https://github.com/Microsoft/BashOnWindows/issues/468
42
+ if ( e . syscall === 'uv_interface_addresses' ) {
43
+ return allAddresses ;
44
+ } else {
45
+ throw e ;
46
+ } ;
47
+ } ;
48
+
36
49
Object . keys ( ifaces ) . forEach ( function ( iface ) {
37
50
var addresses = { } ;
38
51
var hasAddresses = false ;
@@ -68,7 +81,7 @@ switch (os.platform()) {
68
81
case 'freebsd' :
69
82
_getMacAddress = require ( './lib/unix.js' ) ;
70
83
break ;
71
-
84
+
72
85
default :
73
86
console . warn ( "node-macaddress: Unknown os.platform(), defaulting to 'unix'." ) ;
74
87
_getMacAddress = require ( './lib/unix.js' ) ;
You can’t perform that action at this time.
0 commit comments