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

Avoid using shell commands for browser detection #237

Open
PayBas opened this issue May 2, 2024 · 2 comments
Open

Avoid using shell commands for browser detection #237

PayBas opened this issue May 2, 2024 · 2 comments

Comments

@PayBas
Copy link

PayBas commented May 2, 2024

const MACOS_GET_BROWSER_LIST_COMMAND = 'ls "/Applications/" | grep -E "Chrome|Firefox|Opera|Safari|Chromium|Edge" | sed -E "s/ /032/"';

in https://github.com/DevExpress/testcafe-browser-tools/blob/master/src/api/get-installations.js#L14 has claimed another victim.

I've just spent an entire evening trying to figure out why TestCafe was throwing errors like:

    "  code: 'E1005',\n" +
    "  data: [ 'chrome:headless' ]\n" +

Eventually found the testcafe --list-browsers command, which returns no output!
And then the arduous undertaking of trying to figure out what the hell was going on.

Turns out it's the aliases and functions in from https://ohmybash.nntoan.com/ that are making MACOS_GET_BROWSER_LIST_COMMAND unreliable for me.

So basically DevExpress/testcafe#3821 again.

It has been opted that this functionality should be reworked in #168 , but it was never actually implemented.

I strongly feel that relying on ls, grep and sed for this on macOS is a bad idea. The whole Bash/Zsh GNU/BSD mess is still very much alive.

It's just way to easy to break stuff. And the end-user has absolutely no idea that the problem could be caused by shell profile settings like aliases. Why would he/she? No other nodejs app/tool works like that. The issue is totally counter-intuitive.

@yasinkocak
Copy link

yasinkocak commented May 3, 2024

Replace it with NodeJS File system (fs)

https://nodejs.org/api/fs.html

like how it works on karma-detect-browsers
https://github.com/litixsoft/karma-detect-browsers/blob/master/index.js#L13

@PavelMor25
Copy link
Contributor

Hello,

Thank you for bringing this issue to our attention. We are aware of it and agree that it needs to be addressed. We will add this task to our backlog, but we cannot give you exact time frames for its resolution. However, if you have any suggestions or solutions in mind, you're welcome to submit them by opening a pull request. We will review it, and if everything looks good, we'll accept it.

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

No branches or pull requests

3 participants