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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

q: How to distinguish Sapling from 馃殏 Steam Locomotive? #597

Open
vegerot opened this issue Apr 7, 2023 · 12 comments
Open

q: How to distinguish Sapling from 馃殏 Steam Locomotive? #597

vegerot opened this issue Apr 7, 2023 · 12 comments

Comments

@vegerot
Copy link
Contributor

vegerot commented Apr 7, 2023

I know what you're thinking.

Wasn't April Fools a week ago?

I can assure you this Issue is no jest. We are having a problem with some tools that support Sapling where they don't work properly on systems with Steam Locomotive 馃殏 (also called sl).

My question is: how can we distinguish between systems that have Sapling installed or 馃殏 ?

ideas:

  • sl --version shows "Sapling ..." 馃殏 --version just shows the 馃殏
  • check man sl inconsistent, not portable with Windows
  • set a timeout on commands invoking sl slow
  • walk up the directory tree and look for .sl directory before invoking sl. Maybe, but this is slow
  • check binary sizes. Sapling is 50Mb and 馃殏 is 34k. We can simply check if sl > 1Mb

I like the last solution best, but would need to resolve symlinks, etc.

馃ぁ

@vegerot
Copy link
Contributor Author

vegerot commented Apr 7, 2023

related: jestjs/jest#14046, jestjs/jest#14061

@strager
Copy link
Contributor

strager commented Apr 7, 2023

I don't see anything in the 馃殏 source code which would let us easily detect it. =\

@strager
Copy link
Contributor

strager commented Apr 7, 2023

Maybe Sapling could distribute two executables: sl and sapling. The latter could be used by scripts or at least feature detection. (sapling could just be a symbolic link to sl, or vice versa.)

@vegerot
Copy link
Contributor Author

vegerot commented Apr 7, 2023

worst idea: the whole point of installing 馃殏 is to troll yourself. If you have decided to subject yourself to it, then you deserve what鈥檚 coming for you.

The main downside is that in Jest it doesn鈥檛 randomly turn your whole screen into a 馃殏, it just hangs and prints a weird error message. imo if Jest took over your terminal with a 馃殏 animation I would be okay with that, because you installed 馃殏 and it鈥檚 your fault. However, if someone installed 馃殏 two years ago and forgot about it, it鈥檚 going to be really hard for them to figure out why their test runner is broken

@strager
Copy link
Contributor

strager commented Apr 7, 2023

if someone installed 馃殏 two years ago and forgot about it, it鈥檚 going to be really hard for them to figure out why their test runner is broken

It sounds like Jest's error reporting needs to be improved.

@dvanoni
Copy link

dvanoni commented Apr 8, 2023

if someone installed 馃殏 two years ago and forgot about it, it鈥檚 going to be really hard for them to figure out why their test runner is broken

I can confirm that it was indeed very hard for me to figure out what was going on. I lost hours to this. 馃槄

@SimenB
Copy link

SimenB commented Apr 8, 2023

FWIW, I think it's a good idea to distribute a "full" name version. Like yarn is both yarn and yarnpkg. But that doesn't really solve the underlying issue

@SimenB
Copy link

SimenB commented Apr 8, 2023

if someone installed 馃殏 two years ago and forgot about it, it鈥檚 going to be really hard for them to figure out why their test runner is broken

It sounds like Jest's error reporting needs to be improved.

How so? AFAICT, if we cannot detect if sl is sapling or not, there's no proper solution I see to this that doesn't involve guessing, crossed fingers, random timeouts and/or a combination of them. I'd love to be proven wrong, tho 馃榾

@vegerot
Copy link
Contributor Author

vegerot commented Apr 10, 2023

Good point. @strager how did you mean "improve Jest's error reporting"?

@vegerot
Copy link
Contributor Author

vegerot commented May 10, 2023

@strager's idea to also ship a sapling binary will help for Windows too, since we could just distribute sapling since sl is a built-in Powershell alias for Set-Location (i.e. cd)

@SimenB
Copy link

SimenB commented May 13, 2024

Our attempt is to detect if the first character of the command is attempting to clear the screen when running sl root - then we're assuming it's steam locomotive: jestjs/jest#15053

I'd still like to see a sapling alias to reduce ambiguity, tho.

@vladh
Copy link

vladh commented May 13, 2024

I came across this issue as something humorous, so sorry if I'm misunderstanding the requirements, but the Steam Locomotive sl can be detected in Node.js by searching for part of the string making up one of the train cars:

const TRAIN_CAR_PATTERN = "|  |_| |_| |_| |_| |";
const fs = require('fs');
const sl = fs.readFileSync('./sl');
const isSteamLocomotive = sl.includes(TRAIN_CAR_PATTERN);

This has the advantage of not requiring you to run sl. Performance could be further improved by not reading the whole binary into RAM in one go.

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

5 participants