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 WSL in vscode #17

Merged
merged 4 commits into from
May 16, 2022
Merged

Conversation

s-h-a-d-o-w
Copy link
Contributor

@s-h-a-d-o-w s-h-a-d-o-w commented Apr 17, 2022

Whenever ps is run in a WSL window in vscode, it prints an error (a "false positive" in a way), causing to pidtree fail.

This work around here is also used in vscode itself.

I don't know whether you want to introduce something like this. As tiny of a change and as simple as it may be, I would understand it if you were to argue that you don't want to start including workarounds for such specific scenarios.
But in case the vscode team either doesn't want to or is unable to address this at the source (this problem has existed for years), this would obviously enable pidtree to be used for tooling in that environment as well. (I recently contributed an improvement to the concurrency behavior of lint-staged that uses pidtree and that I ironically haven't been able to benefit from because I happen to use WSL...)

@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2022

Codecov Report

Merging #17 (5a06c98) into master (5ebe846) will increase coverage by 1.44%.
The diff coverage is 100.00%.

❗ Current head 5a06c98 differs from pull request most recent head 75bf8b0. Consider uploading reports for the commit 75bf8b0 to get more accurate results

@@            Coverage Diff             @@
##           master      #17      +/-   ##
==========================================
+ Coverage   86.95%   88.40%   +1.44%     
==========================================
  Files           6        6              
  Lines         138      138              
==========================================
+ Hits          120      122       +2     
+ Misses         18       16       -2     
Impacted Files Coverage Δ
lib/bin.js 86.95% <100.00%> (+8.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ebe846...75bf8b0. Read the comment docs.

@huan
Copy link
Collaborator

huan commented Apr 25, 2022

Hi @s-h-a-d-o-w ,

Thanks for adding this to the project! I think it's fine because VSCode code is using it too.

Could you please add a unit test to make sure this works in our code base so that we can have enough confidence to approve it?

Thank you very much.

@s-h-a-d-o-w
Copy link
Contributor Author

Done. Apologies for missing that!

I hope they are alright because... I'm not a fan of these redundancies myself. But looking at the already existing tests and skimming the mockery docs (as well as attempting to remove some of those redundancies), this seemed to me like a conscious decision by the original author and so I ended up following suit.

@huan
Copy link
Collaborator

huan commented Apr 27, 2022

Thanks for adding the unit test!

I think this PR is good and I'd like to approve this PR after the CI turns green.

Copy link
Collaborator

@huan huan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simonepri

@juliomrc
Copy link

Hey! Thank you for this fix.
We are also being affected by this issue. Any prediction on when this will be merged and published?

Thanks a lot!

@huan
Copy link
Collaborator

huan commented May 16, 2022

@juliomrc could you please give an approval to this PR to help us confirm this code is ok?

@simonepri I think this PR will be good to go, and I will merge it if you do not against it and after it get another approval.

Copy link

@juliomrc juliomrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@huan huan merged commit cebc29f into simonepri:master May 16, 2022
@juliomrc
Copy link

@huan thanks for the quick action.
Will you also release the patch to npm?

@huan
Copy link
Collaborator

huan commented May 17, 2022

@juliomrc Unfortunately, I have no permission to publish to NPM, and this repo has not been configured in any DevOps pipeline.

We need to wait for @@simonepri for publishing it.

simonepri added a commit that referenced this pull request Jun 4, 2022
Closes #17

Co-Authored-By: Andreas Opferkuch <[email protected]>
@simonepri
Copy link
Owner

simonepri commented Jun 4, 2022

Sorry everybody for being so late to the party!

I took a look at the PR, and I'm okay with implementing a workaround for this issue, but I'm not sure I like how we implemented it in this PR as it can cause us to ignore more than just the bogus screen error.

I took the liberty to change the code to strip the message from the error stream instead, so that we can ignore only that particular error message.

Please take a look, and confirm this will work as intended:
383dfe6

I'll release a new version as soon this is confirmed.
Thanks a lot for the help!

simonepri added a commit that referenced this pull request Jun 4, 2022
Closes #17

Co-Authored-By: Andreas Opferkuch <[email protected]>
@simonepri
Copy link
Owner

simonepri commented Jun 5, 2022

I released a new 0.6.0 version, let me know if this solves the issue.

@juliomrc
Copy link

juliomrc commented Jun 6, 2022

This fix works as intended and the edge case integration with lint-staged no longer produces a problem.
Thank you!

@s-h-a-d-o-w
Copy link
Contributor Author

@simonepri

it can cause us to ignore more than just the bogus screen error.

That's fair but... on the one hand, I wonder whether ps ever produces other errors when this one occurs (but I'm fine with your adjustments, so I will not invest the time looking into this) and on the other, since you are checking for a more specific error message it is obviously more brittle to changes (not that that's likely after all these years...).

That said...

Thanks a lot for the help!

... and thanks to you for making WSL users happy! I wasn't sure whether it would happen since the last release here was a long time ago (I guess there simply haven't been any issues - which is awesome), so I'm really grateful. 🙂

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.

5 participants