dsherret / dax

Cross-platform shell tools for Deno and Node.js inspired by zx.
MIT License
1.02k stars 34 forks source link

`PathRef.basename()` is confusing #185

Closed greentore closed 9 months ago

greentore commented 11 months ago

I find it confusing that a method named basename returns filenames with extensions. It also doesn't help that there's no ergonomic way to get the bare filename (withExtname("") contains a trailing dot). In my opinion Python's pathlib's stem and name terminology for bare and full filenames respectively is more intuitive.

dsherret commented 11 months ago

This is copied from the terminology and functionality that's already familiar in the JavaScript ecosystem: https://nodejs.org/api/path.html#pathbasenamepath-suffix which is copied from unix https://en.m.wikipedia.org/wiki/Basename

I'm also not a fan of the terminology, but it's very common. Personally I would have preferred to call it .filename() (where file names refer to only the last component and file paths are with multiple components), but that would have diverged from this already common naming and I'm not sure that would be good to do.

I opened an issue for the bug you mentioned https://github.com/dsherret/dax/issues/186