-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add utility to retrieve user's home directory #67
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
Conversation
| ## Usage | ||
|
|
||
| ``` javascript | ||
| var homedir = require( '@stdlib/lib/node_modules/@stdlib/utils/homedir' ); |
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.
The require statement is incorrect.
|
|
||
| If unable to locate a `home` directory, the module returns `null`. | ||
|
|
||
| ``` javascript |
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.
I am not sure we should include this example. Could cause issues if we ever perform automated testing of doc examples.
|
|
||
| ## Notes | ||
|
|
||
| * This module primarily checks various [environment variables][environment-variables] to locate a `home` directory. Note that this approach has __security vulnerabilities__, as attackers can tamper with [environment variables][environment-variables]. |
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.
The implementation primarily checks...
| ## Examples | ||
|
|
||
| ``` javascript | ||
| var homedir = require( '@stdlib/lib/node_modules/@stdlib/utils/homedir' ); |
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.
Require statement is incorrect.
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function returns the `/root` directory if run as `root` in a linux environment', function test( t ) { |
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.
All instances of linux => Linux in string descriptions.
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function returns a home directory in a Mac OSX environment (USERNAME)', function test( t ) { |
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.
All instances of OSX => OS X in string descriptions.
| // Get the current user account (https://docs.python.org/2/library/getpass.html): | ||
| user = env[ 'LOGNAME' ] || env[ 'USER' ] || env[ 'LNAME' ] || env[ 'USERNAME' ]; | ||
|
|
||
| // If on Mac OSX, use the Mac path convention (http://apple.stackexchange.com/questions/119230/what-is-standard-for-os-x-filesystem-e-g-opt-vs-usr)... |
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.
OS X
| </section> | ||
|
|
||
| <!-- /.examples --> | ||
|
|
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.
Missing CLI docs.
| // e.g., returns '/Users/<username>' | ||
| ``` | ||
|
|
||
| If unable to locate a `home` directory, the module returns `null`. |
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.
...the function returns
null.
|
Could you take another look? |
| <!-- /.references --> | ||
|
|
||
|
|
||
| --- |
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.
CLI docs go above the "references" section.
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function supports older Node versions', function test( t ) { |
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.
How does this test whether the implementation supports older Node versions? Considering how this package works, this should be in the other test file.
kgryte
left a comment
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.
Need to confirm test works as intended.
|
|
||
| opts = { | ||
| 'os': { | ||
| 'homedir': void 0 |
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.
Can you confirm that this works as intended? Possible that proxyquire ignores homedir when set to undefined, falling back to the original implementation. If so, can set to false.
This should be apparent when generating a coverage report and whether all code branches are covered (notably within the main index.js file).
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.
Yes, can confirm that we reach 100% code coverage for homedir.
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.
Including branch coverage?
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.
Yes.
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.
Must be because os does get mocked with an empty object. Makes sense.
Resolves #60 .
Checklist
develop.developbranch.Description
This pull request:
stdlib.Related Issues
This pull request:
Questions
No.
Other
No.
@stdlib-js/reviewers