-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Use folder-hash
instead of hash-files
.
#45
Conversation
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.
Love the fix, just some stylistic concerns.
src/utils.ts
Outdated
return (await hashElement(path, { encoding: "hex", folders: { ignoreRootName: true } })).hash; | ||
} | ||
|
||
export async function hashFiles(patterns: string[] = []): Promise<string> { | ||
const hasher = crypto.createHash("md5"); | ||
const nodes = (await glob(patterns)).sort().map((filename) => hashElement(filename)); | ||
(await Promise.all(nodes)).forEach((node) => hasher.update(node.hash)); |
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.
In both of these cases, can you assign the await
result to an intermediate variable and then use it? (await <complex expression>).<stuff>
is not very readable, and return (await <complex expr>).<stuff>
is even worse.
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.
You're right, I hadn't noticed how ugly it was before. I've changed it, could you have a look if it is better now? ;)
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.
Sure, will look in a minute!
For situations like this, self-reviewing your PR in the GitHub interface right after you open it is super useful. When you're in the middle of trying to get things working, things like these are easy to miss. But I bet you would have noticed both issues I flagged here by yourself in a self-review — I don't think I contributed anything special there.
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 always go through the changes I made in the GitHub interface, and this was the case too, but maybe I wasn't careful enough. I'll try to do better next time!
Would you care to tag the latest Remember that it's important to minimize the time the repo is missing a For best results, I recommend:
I trust you to do this. If for any reason you'd prefer not to, just let me know and I'll take care of it. |
Done! Thank you for the detailed instruction, it was very useful ;) |
Happy to help! |
Closes #44.
The deprecation warning originated in package
hash-files
. It was the simplest one to use, but hasn't been maintained since 2016. I switched tofolder-hash
(https://www.npmjs.com/package/folder-hash), with latest release from January, which seems to be the most popular one now.