-
Notifications
You must be signed in to change notification settings - Fork 7
Simplify source code while visiting few cli/ sources
#125
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
|
This change attempts to separate the Xcframework linking logic from the directory iteration by extracting the "glob-like" function out. This change also opens the door for easier migration to a proper glob() function.
| withFileTypes: true, | ||
| }) | ||
| // Following extracted function mimics `glob("*/*.framework/")` | ||
| function globFrameworkDirs<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.
Nit: this can be moved to path-utils
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.
Since this also applies a side-effect, it feels to me that it's doing a bit more than simply globbing?
Perhaps
| function globFrameworkDirs<T>( | |
| function globAndPrepareFrameworks<T>( |
cli/ sourcescli/ sources
| // Expect the library in the new location | ||
| assert(fs.existsSync(newLibraryPath)); | ||
| // Update the binary | ||
| await spawn( |
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.
nit: imho this should be extracted to a separate function
| path.join(dependency.path, modulePath) | ||
| ); | ||
| } | ||
| const absoluteModulePaths = Object.values(dependenciesByName).flatMap( |
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.
💙
| } else { | ||
| throw error; | ||
| } | ||
| absoluteModulePaths.map(async (originalPath) => { |
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.
💙
| // Following extracted function mimics `glob("*/*.framework/")` | ||
| function globFrameworkDirs<T>( | ||
| startPath: string, | ||
| fn: (parentPath: string, name: string) => Promise<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.
Could we pick a more semantic name for this argument? It's like an action performed on every triplet + framework.
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.
Not feeling strongly for any of my suggestions: Merge at will 👍
I'm in the process of fixing some errors that I'm getting after integrating major changes from
main, and while looking for the root-cause of those issues, I decided to do some minor code cleanups and simplifications while visiting some of the files.This PR will leave the DRAFT status as I fix all the issues.