Closed edouard-lopez closed 5 years ago
@edouard-lopez I disagree on code readability, but I'm curious to know how $filename
is prone to conflicts? Recall that tests run in their own subshell.
Your source
trick will not work, because $filename
is really just the name, not the full path, so I'm positive about adding $dirname
back.
$dirname
→ /Users/foo/bar
$filename
→ test.fish
What about also?
$pathname
→ /Users/foo/bar/test.fish
Too much? :)
Readability is not that bad indeed.
In several scripts I wrote, I rename files and use $filename
as the variable name that contains the filename extracted from a path. Sure the subshell might prevent conflict, but shouldn't we know it's a fishtape variable and not one from our script?
I tend to prefer $filepath
over $pathname
.
To have both $dirname
, $filename
and $pathname
seem a bit redundant.
@edouard-lopez Like this?
$fishtape_dirname
→ /Users/foo/bar
$fishtape_filename
→ test.fish
Any ideas for more variables?
LGTM.
No other requirement for me at the moment.
Added in https://github.com/jorgebucaran/fishtape/commit/b195bc15de838887a153e6ad50555a04085ce307 (here).
In the end I went with$current_dirname
and $current_filename
instead.
Release notes coming up later! 👋
related:
2.0.0
, #38Thanks for the new release, I haven't made the switch yet, but look forward to it.
In the release note for
2.0.0
you mention removing$DIRNAME
variable. That annoying, cause I'm using it a on every test files forpure
to import function under test, like:Sure it's possible to use
$filename
however such a name is prone to conflict and makes code a less readable:BATS as a series of special variables prefixed by
$BATS_TEST_
(e.g.$BATS_TEST_DIRNAME
).I reckon namespacing is a must have, and would love to see
dirname
come back :heart:Some namespace ideas: