Sunday, 16 June 2019

What is the reason behind packages like is-windows?

Over at /r/programming there is currently a thread "discussing" npm-packages like is-windows, which consists of only a few lines.I'm trying to find a reason for those packages to exist:My initial first thought was, that these packages are from the early days of node.js where it wasn't as easy as process.platform === 'win32' to find out what platform it's running on, but that is pretty much what this packages does, it also checks for cygwin and msys in the environment, so you have at least these two corner cases to justify the package. So maybe in the future there will be more corner cases and if you install these packages, you don't have to think about what will be?On the other hand there is a package from the same author called is-invalid-path, which "Returns true if a windows file path has invalid characters.", which has a bug for over a year, and that bug is in a function that checks if the system is windows or not! I don't understand why he doesn't use his own is-windows?My second thought was, that those packages were only used as direct dependency by other (more useful) packages of the same author, which means that packages from other people only use this as a transitive/indirect dependency.While this is maybe partly true - in a different packet from him he uses it simply to change the color from cyan to blue on windows system, for a reason unknown to me - there are still a lot of direct dependencies from other people: e.g. cross-env, which is popular (over 1million downloads per week and almost 4k stars on GitHub) only has two(!) direct dependencies in total, one of them is is-windows. I was thinking about opening an issue asking the author what the reason was behind adding this dependency, but there is already enough circlejerk going on right now, so I thought I would ask here instead of bothering the author.

Submitted June 16, 2019 at 03:48PM by 0xnoob

No comments:

Post a Comment