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

Add support for Windows Subsystem for Linux (WSL) #20

Merged
merged 4 commits into from Oct 19, 2018

Conversation

addisonElliott
Copy link
Contributor

@addisonElliott addisonElliott commented Oct 9, 2018

WSL does not support netstat or lsof yet. Therefore, the PID can be retrieved from ps 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 and lsof. microsoft/WSL#2249

However, 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

Need to work towards detecting if using WSL and then using the Powershell WSL version that is essentially the same as netstat.
@danielkrainas
Copy link
Owner

Hi @addisonElliott - thank you for the submission and sorry for the huge delay. I'll give this another look tonight but it should be good.

@addisonElliott
Copy link
Contributor Author

No problem, we're all busy so I completely understand!

@danielkrainas danielkrainas merged commit 3d84efc into danielkrainas:master Oct 19, 2018
@danielkrainas
Copy link
Owner

Thank you again for the submission! Published and available in v1.5.0

@addisonElliott addisonElliott deleted the add-wsl-support branch October 22, 2018 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants