-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Thunkify homeDirectory lookup #32
Conversation
@@ -270,3 +272,8 @@ test('handle undefined', t => { | |||
const expected = undefined; | |||
t.is(cleanStack(stack, {pretty: true}), expected); | |||
}); | |||
|
|||
test('exports for home-directory files match', 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.
I don't really see the point of this test.
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.
Initially I didn't update home-directory-browser.js
with the same change, which would've broken browser behavior. I figured it would be nice to have a test to help ensure the return type from both files is symmetric.
index.js
Outdated
@@ -40,7 +40,7 @@ export default function cleanStack(stack, {pretty = false, basePath} = {}) { | |||
} | |||
|
|||
if (pretty) { | |||
line = line.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(homeDirectory, '~'))); | |||
line = line.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(getHomeDirectory(), '~'))); |
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.
This is super inefficient. It will fetch os.homedir()
for every line.
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.
If
pretty === false
, do not invokeos.homedir()
.I reason calls to
os.*
should only occur when the user configures behavior provided by this library that require them.