-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #655 Credit: @isaacs Close: #655 Reviewed-by: @mikemimik
- Loading branch information
Showing
1 changed file
with
22 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7dbb914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my god, what a fine club to be in.
7dbb914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what a terrible nesting, I would this refactor to define some map of env variables => ci name, and iterate over the map.
7dbb914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glensc It's refactored away entirely into
@npmcli/ci-detect
, but we can't bundle scoped modules into the CLI until v7, due to a bug in how npm v3 handled bundled scoped deps. (npm v3 ships with Node v6, which is the oldest Node.js version supported by npm v6).7dbb914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but still same code there :)
7dbb914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But without standard's abusive indentation.
A series of ternaries is ideal for this use case, because it is the formulation that affords the minimum amount of flexibility. When you see a start of a ternary, you know that the only possible use is
(conditional expression) ? (expression) : (expression)
. There's no possibility for it to have multiple non-expression statements. It cannot throw, return, fail to set the initially assigned variable, etc.A good rule of thumb in programming is to always use the code form that grants as much flexibility as needed, but no more, so that a reader can "switch off" scanning for other possible behaviors. This is why types are good (and really, imo, the only relevant reason why types are good), why arrow functions and classes are better than
function
, why brace-less arrow functions andif/else
are better than braced, etc.Keep your flexibility small, so that the intention of a block of code is clear. This is, in the long run, a much more useful and pragmatic rubric than "make it easy to read", because what is "easy to read" depends more on subjective personal experience and the whims of fashion than anything else. Your entire future will be spent as a person with more experience than you have today; optimize for that person, not this one.