mirror of
https://github.com/sbrow/envr.git
synced 2026-06-27 10:38:33 -04:00
refactor: App now crashes if home isn't set.
This commit is contained in:
2
TODOS.md
2
TODOS.md
@@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
7. Make sure official path separators are used when appropriate, rather than '/'.
|
7. Make sure official path separators are used when appropriate, rather than '/'.
|
||||||
|
|
||||||
10. **config.odin:178** — `search_paths` silently ignores `os.user_home_dir` error. If home is empty, `~` isn't expanded. Same class of bug as issue 3.
|
|
||||||
|
|
||||||
12. Consistently ignore allocator errors
|
12. Consistently ignore allocator errors
|
||||||
|
|
||||||
13. **cmd_sync.odin:80, cmd_list.odin:33** — `make([]string, 2)` for table rows never freed. Leaks per row. Defer to memory pass.
|
13. **cmd_sync.odin:80, cmd_list.odin:33** — `make([]string, 2)` for table rows never freed. Leaks per row. Defer to memory pass.
|
||||||
|
|||||||
10
config.odin
10
config.odin
@@ -208,17 +208,19 @@ find_git_roots :: proc(
|
|||||||
}
|
}
|
||||||
|
|
||||||
search_paths :: proc(cfg: Config, allocator := context.allocator) -> [dynamic]string {
|
search_paths :: proc(cfg: Config, allocator := context.allocator) -> [dynamic]string {
|
||||||
// TODO: handle error
|
home, err := os.user_home_dir(context.temp_allocator)
|
||||||
home, _ := os.user_home_dir(context.temp_allocator)
|
if err != nil {
|
||||||
|
panic("Failed to find home directory")
|
||||||
|
}
|
||||||
|
|
||||||
paths, _ := new_clone(cfg.scan_config.include, allocator)
|
paths := new_clone(cfg.scan_config.include, allocator)
|
||||||
|
|
||||||
for &include in paths {
|
for &include in paths {
|
||||||
// TODO: Do we need to manually expand ~/ in odin?
|
|
||||||
expanded, _ := strings.replace(include, "~", home, 1, allocator)
|
expanded, _ := strings.replace(include, "~", home, 1, allocator)
|
||||||
if filepath.is_abs(expanded) {
|
if filepath.is_abs(expanded) {
|
||||||
include = expanded
|
include = expanded
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: show errors?
|
||||||
resolved, err := filepath.abs(expanded, allocator)
|
resolved, err := filepath.abs(expanded, allocator)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
include = resolved
|
include = resolved
|
||||||
|
|||||||
Reference in New Issue
Block a user