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

Convert some parts to async await and simplify #49

Merged
merged 2 commits into from
Jan 6, 2025
Merged

Conversation

thgreasi
Copy link
Contributor

@thgreasi thgreasi commented Dec 30, 2024

Change-type: patch

@thgreasi thgreasi changed the title Simplify Convert some parts to async await and simplify Dec 30, 2024
@thgreasi thgreasi force-pushed the simplify branch 2 times, most recently from bb401ab to eb1105c Compare December 31, 2024 15:10
@thgreasi thgreasi marked this pull request as ready for review December 31, 2024 15:19
@thgreasi thgreasi requested a review from a team December 31, 2024 15:19
target,
getConfigPathDefinition(manifest, CONNECTIONS_FOLDER),
Copy link
Contributor Author

@thgreasi thgreasi Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All that this was doing was setting path=CONNECTIONS_FOLDER to the result of definitionForImage(), which we then read in readdirAsync(connectionsFolderDefinition.path);.
So the reasoning of this refactoring (which I repeat all of the place) was to avoid the extra destructing and make things simpler by directly referencing the CONNECTIONS_FOLDER in the readdirAsync (9 lines lower), since readdirAsync(CONNECTIONS_FOLDER); reads easier than readdirAsync(connectionsFolderDefinition.path);

The change in src/utils.ts is an easier case that also demonstrates the same idea applied here.


// Fresh image, new format, according to https://github.com/resin-os/meta-resin/pull/770/files
if (_.includes(files, 'resin-sample.ignore')) {
const inputDefinition = utils.definitionForImage(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeats what we did in const connectionsFolderDefinition = utils.definitionForImage() above, and just sets a different path. Since we no longer access the .path via this result, we can run definitionForImage() just once and re-use it in all branches w/ just different inline paths ${CONNECTIONS_FOLDER}/resin-sample.ignore in this case

@thgreasi thgreasi enabled auto-merge December 31, 2024 16:04
@thgreasi thgreasi requested a review from a team December 31, 2024 19:05
@thgreasi thgreasi requested review from a team and joshbwlng and removed request for a team January 3, 2025 14:26
@thgreasi thgreasi merged commit b8460b2 into master Jan 6, 2025
84 of 102 checks passed
@thgreasi thgreasi deleted the simplify branch January 6, 2025 06:36
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.

2 participants