-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add sync script #13
Add sync script #13
Conversation
I like the idea but the implementation could be improved:
|
Any idea of how to do that? I couldn't find a simple solution.
I can take care of that. |
What changes across the platforms are the arguments provided to the exec* methods and the processing of the output. If we extract those in a map whose key is the platform (with a catch-all option) we will limit the duplication to the strictly necessary to provide the 2 types of sync/async apis.
Thanks |
Thanks for the suggestion, all done! |
All good now, @simoneb could you check? |
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.
Looks good. Can you add type tests in https://github.com/simoneb/fast-folder-size/blob/master/types/index.test-d.ts?
I did, but how do I import |
I don't know, I'm not a ts expert :) |
Me neither 🤣 |
Look up how other packages are doing this perhaps. Anyway, from within the type tests I believe you need to import |
Alright, it works all fine now, found a way. The types I did were based on this stackoverflow answer |
declare module 'fast-folder-size/sync' { | ||
export = fastFolderSizeSync | ||
} |
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.
despite the tests passing, I have a feeling that defining the types this way will not let a typescript consumer use it in the way you intend it:
import fastFolderSizeSync from 'fast-folder-size/sync'
// or
const fastFolderSizeSync = require('fast-folder-size/sync')
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 think it's correct, what are you proposing?
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'm happy to merge and release a new version. Will you have a chance to try the released package to see if the typings work correctly?
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.
Okay I will!
Sometimes, some packages use just the sync commands of node, no await.
It would be useful if this package offered a sync version as well.
With this PR, you would import it and use it like this: