Skip to content
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

Merged
merged 3 commits into from
Apr 30, 2023

Conversation

mgr0dzicki
Copy link
Collaborator

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 to folder-hash (https://www.npmjs.com/package/folder-hash), with latest release from January, which seems to be the most popular one now.

Copy link
Owner

@obi1kenobi obi1kenobi left a 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.

jest.config.js Outdated Show resolved Hide resolved
src/utils.ts Outdated
Comment on lines 40 to 46
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));
Copy link
Owner

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.

Copy link
Collaborator Author

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? ;)

Copy link
Owner

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.

Copy link
Collaborator Author

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!

@obi1kenobi obi1kenobi merged commit ca4682c into obi1kenobi:main Apr 30, 2023
@obi1kenobi
Copy link
Owner

Would you care to tag the latest main as v2.1 and then move the v2 tag to that new commit as well?

Remember that it's important to minimize the time the repo is missing a v2 tag, because any actions that use the tag and run in that time will fail.

For best results, I recommend:

  • make the v2.1 tag locally and push it
  • delete the v2 tag locally
  • make the new `v2 tag locally
  • git push origin <tag-name> --delete && git push origin <tag-name> to replace the v2 tag as quickly as possible

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.

@mgr0dzicki
Copy link
Collaborator Author

Done! Thank you for the detailed instruction, it was very useful ;)

@mgr0dzicki mgr0dzicki deleted the folder_hash branch May 2, 2023 07:38
@obi1kenobi
Copy link
Owner

Happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node Buffer-related deprecation warning
2 participants