-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
normalize paths #80
Comments
This should happen in vinyl |
Thanks, should it only happen on construction? I was also thinking that glob-stream should maybe do it so there aren't incorrect paths being streamed on Windows (glob stream emits plain objects, not Vinyl objects) |
@contra - How would this work reliably in Would normalization of paths apply to all Is there code kicking around to normalize the paths anywhere? I found https://github.com/gulpjs/vinyl-fs/blob/master/lib/src/wrapWithVinylFile.js#L9, not sure if that is the current solution? |
@Marak that's currently where we do the normalization (in glob-stream - https://github.com/gulpjs/glob-stream/blob/master/index.js#L50) but my thinking is that we should use |
Correction: that got moved into glob-stream at https://github.com/gulpjs/glob-stream/blob/master/index.js#L50 |
I haven't done much windows testing, If so, seems like it would be a simple fix to |
@Marak yeah, node's |
Cool. I'm putting Been doing a general review of the ecosystem and core libs. Very impressed with everything. Thank you. |
Replying to #92 (comment) here since this is the place for it :)
Why should directory paths end in separator? |
@darsain since we already use Some examples: // This doesn't currently work
var file = new Vinyl({ path: '/test/123.jpg' });
file.dirname + file.basename === file.path
// Instead you must use path.join which adds another function call
path.join(file.dirname, file.basename) === file.path
// This also doesn't work
file.dirname + file.stem + file.extname === file.path
// So you have to use path.join AND string concatenation
path.join(file.dirname, file.stem + file.extname) === file.path These inconsistencies also resulted in unexpected results when I was refactoring the vinyl-fs tests. We need to make the behavior consistent and easy to work with. |
@darsain any progress on this? If not, I might be tackling it soon. |
@phated other things creeped in :/ should get back to it sometime in the next few days. |
Should we throw in Otherwise, accessing stuff like The solutions are:
Is In tests, I see that |
@darsain how would you actually set the path to empty? Is there a code path that allows it? |
@phated sorry, Going thought the code again made me realize that it already answers these questions, as well as handles the no path case in a solid way :) But to answer your question, |
Finishing up a PR, have hopefully 2 last questions:
Edit: Actually, the path module has 2 versions, posix and win32, and the default one can't be flipped just by setting |
@darsain I think Aside: I'm excited to see this PR. |
@phated damn, just submitted the PR without trailing sep for basename :) gonna add it in. |
In testing on Windows, I found that the slashes in the path history were incorrect. It seems these are coming from node-glob but we aren't doing any translation.
Not sure where we should do this, but in the meantime, I am normalizing in vinyl-fs before we construct the
Vinyl
object because it requires the least releases.cc @contra
The text was updated successfully, but these errors were encountered: