Skip to content

Instantly share code, notes, and snippets.

@therealkenc
Created August 12, 2016 22:39
Show Gist options
  • Save therealkenc/c9b36e5e648a9525a3461ad009737014 to your computer and use it in GitHub Desktop.
Save therealkenc/c9b36e5e648a9525a3461ad009737014 to your computer and use it in GitHub Desktop.
const os = require("os");
const fs = require("fs");
const Emitter = require('events');
var wslNetworkInterfaces = function() {
console.log("WSL has no idea what interfaces are available.");
return {
"Loopback Pseudo-Interface 1": [
{
"address": "::1",
"netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
"family": "IPv6",
"mac": "00:00:00:00:00:00",
"scopeid": 0,
"internal": true
},
{
"address": "127.0.0.1",
"netmask": "255.0.0.0",
"family": "IPv4",
"mac": "00:00:00:00:00:00",
"internal": true
}
]
};
}
class WSLFSWatcher extends Emitter {}
var wslWatchFile = function(file) {
console.log("WSL isn't really watching " + file.toString());
}
var wslUnwatchFile = function(file) {
console.log("WSL wasn't really watching " + file.toString());
}
var wslWatch = function (file) {
console.log("WSL isn't really watching " + file.toString() +
" and FSWatcher is lying.");
return new WSLFSWatcher();
}
console.log("running wsl-shim");
// make it easy to comment out shims
os.networkInterfaces = wslNetworkInterfaces;
fs.watchFile = wslWatchFile;
fs.unwatchFile = wslUnwatchFile;
fs.watch = wslWatch;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment