-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: allow checkPlatform to override execution environment #65
Conversation
lib/index.js
Outdated
if (force) { | ||
return | ||
} | ||
|
||
const platform = process.platform | ||
const arch = process.arch | ||
const platform = environment && environment.os ? environment.os : process.platform |
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.
Since we're defaulting environment to {}
here we don't need the environment &&
guard.
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.
@wraithgar Callers of this function may still pass null
or undefined
for this argument while the default value is {}
. How about leaving the environment &&
guard as it is and changing the default value to undefined
?
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.
We typically don't guard against bad input. It (arguably unnecessarily) increases the cognitive load of maintaining this module. This is a style choice inside of the npm codebase, we don't need to support the extra falsey value, folks consuming this can omit the parameter.
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.
@wraithgar Okay, that makes sense! Let's prioritize the consistency across the codebase. 76b0df6
This is going to need tests. |
I've added tests here: d9b4234 |
updated the PR title |
the PR title linting is broken, had a snafu w/ the template-oss template. Don't worry about it. |
Co-authored-by: Gar <[email protected]>
@wraithgar Hi, sorry for bothering you but let me kindly remind. When is this getting released and included in npm/cli? I'd like to start working on npm/rfcs#612. |
@yukukotani This will be released with the next |
This PR allows
checkPlatform
to override execution environment which comes fromprocess.platform
andprocess.arch
by default.This will be required to achieve npm/rfcs#612
References