Skip to content

refactor(common): replace path helper functions with variables#17

Open
CheapFuck wants to merge 1 commit into
codam-coding-college:mainfrom
CheapFuck:refactor/path-helpers-to-vars
Open

refactor(common): replace path helper functions with variables#17
CheapFuck wants to merge 1 commit into
codam-coding-college:mainfrom
CheapFuck:refactor/path-helpers-to-vars

Conversation

@CheapFuck

Copy link
Copy Markdown

Summary

Closes #1.

towel_exports_bin_dir, towel_exports_apps_dir, towel_host_bin_dir and towel_host_apps_dir were single-line functions that only echoed a constant path. As the issue notes, these should just be variables.

Change

Replace the four functions with variables evaluated once when towel-common is sourced:

Old function New variable
towel_exports_bin_dir TOWEL_EXPORTS_BIN_DIR
towel_exports_apps_dir TOWEL_EXPORTS_APPS_DIR
towel_host_bin_dir TOWEL_HOST_BIN_DIR
towel_host_apps_dir TOWEL_HOST_APPS_DIR

All 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 -x across all scripts: pass
  • shfmt -d across all scripts: pass

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
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.

Functions that should be variables

1 participant