Closed pgilad closed 9 years ago
@pgilad That is correct though, /Users/pgilad/repos/personal/gulp-todo/lib/reporter.js
relative to /
is Users/pgilad/repos/personal/gulp-todo/lib/reporter.js
- I don't understand the problem. Why would a plugin use the relative path?
Because if you do any kind of action of collecting filenames (and possibly outputting them somehow) the user may want to control if the output is either relative (usually lib/reporter.js
) or absolute (usually /Users/pgilad...
).
Each have their own usage, and a user of my plugin recently requested absolute paths in order to use with a CI tool (jenkins).
Point being - when writing a plugin, I would like it if users can control the path output of files by themselves. I realize that may be difficult and probably impossible to achieve via the base
option.
Does that make sense, @contra?
@pgilad Can you link the github issue?
sure. I already closed it by adding the absolute
option thought. :sob:
https://github.com/pgilad/gulp-todo/issues/27
@pgilad I think the way you solved it works fine, I'm not sure what you're proposing we add to gulp (or vinyl) to help you out
@contra I'm not sure either, but I found path.relative
works fine in almost all cases except when user supplies base
path of /
. I do realize it makes sense that Users/pgilad...
is relative to /
but then again - if someone supplies base path /
they probably want absolute paths.
I guess this can be closed, I thought there might be a hidden solution I wasn't aware of
Currently
file.relative
returnspath.relative(file.base, file.path)
.This works great, but when you want a plugin to use
file.relative
and supplybase: '/'
, you get file paths that are non-absolute, and are incorrect (but are correct relative to root):So you would get:
This problem occurs when you use
file.relative
in your plugin to get file information, and expect users to set thebase
option in order to control if the path will be absolute or relative.Any ideas on how to work around this without adding an option to the plugin?