Add support for Windows Subsystem for Linux (WSL) #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WSL does not support
netstat
orlsof
yet. Therefore, the PID can be retrieved fromps
command but the port is not found for the PID.Microsoft has said they are working on the issue and hopefully a future release will support
netstat
andlsof
. microsoft/WSL#2249However, a solution that works is to use netstat for Windows in WSL which can be called by simply running the command netstat.exe. (If you just do netstat, then it uses the Linux netstat which does not return processes).
The rest of this PR is including an is-wsl library to check if using WSL because otherwise the os.platform will return Linux. If using WSL, default to win32 platform.
Note: I was debating whether or not to include is-wsl and check for that or just rely on the developer to manually set the
platform
option to win32 if using WSL. If you prefer the latter option, let me know and I can make this PR just switch netstat to netstat.exe command.This is necessary for me to add support for is-mongodb-running module to work correctly in WSL. See here: mongodb-js/is-mongodb-running#8