refactor(common): replace path helper functions with variables#17
Open
CheapFuck wants to merge 1 commit into
Open
refactor(common): replace path helper functions with variables#17CheapFuck wants to merge 1 commit into
CheapFuck wants to merge 1 commit into
Conversation
towel_exports_bin_dir, towel_exports_apps_dir, towel_host_bin_dir and towel_host_apps_dir were single-line functions that just echoed a static path. Replace them with plain variables (TOWEL_EXPORTS_BIN_DIR, TOWEL_EXPORTS_APPS_DIR, TOWEL_HOST_BIN_DIR, TOWEL_HOST_APPS_DIR) computed once when towel-common is sourced, and update every call site to use them. This drops a subshell per lookup and reads more clearly. No behavioural change: the paths are constant for the lifetime of the process. Closes codam-coding-college#1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1.
towel_exports_bin_dir,towel_exports_apps_dir,towel_host_bin_dirandtowel_host_apps_dirwere single-line functions that onlyechoed a constant path. As the issue notes, these should just be variables.Change
Replace the four functions with variables evaluated once when
towel-commonis sourced:towel_exports_bin_dirTOWEL_EXPORTS_BIN_DIRtowel_exports_apps_dirTOWEL_EXPORTS_APPS_DIRtowel_host_bin_dirTOWEL_HOST_BIN_DIRtowel_host_apps_dirTOWEL_HOST_APPS_DIRAll call sites (all within
towel-common) are updated to reference the variables, dropping a subshell per lookup.No behavioural change: the paths are constant for the lifetime of the process.
Testing
shellcheck -xacross all scripts: passshfmt -dacross all scripts: pass