gulpjs / vinyl

Virtual file format.
MIT License
1.28k stars 107 forks source link

Remote paths #127

Open bezoerb opened 7 years ago

bezoerb commented 7 years ago

First I would like to thank you for your work on this module. Version 2 brought some internal changes which prevent the use of vinyl for remote objects. Prior to v2 it was possible to store an url as path. The use of path.normalize introduced in v2 breaks this "feature" ;) Is this the intended behaviour or would you accept a PR to "fix" this?

yocontra commented 7 years ago

Yeah, that was a mistake! Vinyl should absolutely support any kind of URL/path - A PR w/ some tests to prevent this in the future would be great

phated commented 7 years ago

This is a hard problem to solve because we need to normalize filesystem paths. There needs to be a module created that determines if a path is fs or remote.

bezoerb commented 7 years ago

PR submitted: https://github.com/gulpjs/vinyl/pull/128

phated commented 7 years ago

Copying my comment from #128 PR:

I actually believe this problem can and should be solved by my idea of an Enhanced Stat Object (#105). Usage would look something like:

var file = new Vinyl({
  path: 'http://google.com',
  stat: {
    isRemote: true
  }
})

The isRemote flag in the Enhanced Stat Object would indicate that a Vinyl resource is being constructed with a remote path and would disable normalization (or do URL normalization). Also, Enhanced Stat Objects would allow for property changes and track history, a non-remote file could be converted to a remote file and users would know where it happened in a pipeline.