Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[expo-cli]<feat>: Add cmd.exe detection on windows & warn about it #2838

Merged
merged 11 commits into from
Dec 9, 2020

Conversation

bbarthec
Copy link
Contributor

@bbarthec bbarthec commented Oct 28, 2020

Resolves #2107

I've only succeeded in checking whether the expo-cli is run from cmd.exe.

HOW

I've found a package that seems to be quite popular and behaves similar to ps aux: https://www.npmjs.com/package/ps-list.
I'm using it to find the parent process of the current running program taking advantage of NodeJS API process.ppid.

The problem with this approach is that on Windows we're querying the processes table and that is taking some time.
I've measured the timings on VMWare Fusion running Windows 10 and checking for cmd.exe takes ~200ms.

PREVIEW

Screenshot 2020-10-28 at 13 20 09

ABOUT WSL

Unfortunately, I've failed to find any reliable way to distinguish between WSL v1 & v2.
There's a package that can detect running the script on WSL though (https://www.npmjs.com/package/is-wsl), but once we're in WSL we don't really need to warn about it 😅

Although there's a way to check WSL version:

PS C:\Users\Bartłomiej Bukowski> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         1 <<- this is version

it only runs in PowerShell/CMD, so we're unable to check from inside WSL what version we're running using this technique.

@bbarthec bbarthec requested review from brentvatne and fson October 28, 2020 09:49
@bbarthec bbarthec marked this pull request as ready for review October 28, 2020 09:50
@brentvatne
Copy link
Member

The problem with this approach is that on Windows we're querying the processes table and that is taking some time.
I've measured the timings on VMWare Fusion running Windows 10 and checking for cmd.exe takes ~200ms.

ah, that's too bad. some ideas:

  • maybe we can make this an asynchronous warning rather than blocking
  • we could cache it per pid so it's only slow the first time you run it in a terminal (seems like a lot of work for a small feature like this)
  • we could move it to expo doctor or expo diagnostics

@bbarthec bbarthec force-pushed the @bbarthec/expo-cli/warn-on-windows branch from b96907b to 82daca0 Compare November 20, 2020 16:16
@bbarthec bbarthec force-pushed the @bbarthec/expo-cli/warn-on-windows branch from 15248a8 to bc32599 Compare November 23, 2020 17:57
@bbarthec bbarthec requested a review from brentvatne November 23, 2020 17:57
@bbarthec
Copy link
Contributor Author

@brentvatne, I've adjusted the warning, detection process (removed the ps-list dependency, bc it is shipped with fastlist binary for windows) and scoped the detection into doctor command.

@brentvatne brentvatne merged commit bfd3e9b into master Dec 9, 2020
@brentvatne brentvatne deleted the @bbarthec/expo-cli/warn-on-windows branch December 9, 2020 00:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strongly suggest using a good terminal for Windows
2 participants