-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Incorrect relative path in gulp.dest() > vinyl-fs #699
Comments
The base (by default) is where the glob starts. If you want to change this you can pass the |
I don't want to change the base. I simply don't want to loose the directories in the relative path when gulp.src is given a string path instead of a glob. In my example above, the |
@demisx Again, this is what "base" means. The path that .dest writes is relative to "base" |
@contra Thank you for the prompt reply. I understand what the base is, but, I don't quite understand why I need to set the |
@demisx How would gulp automatically figure out what path you want to be the base if you don't use a glob? In your example it could be either |
Sorry for interrupt. Its Looking at this glob-stream line |
@stringparser There still seems to be a miscommunication here - maybe I'm failing to articulate my point: There are two possible cases -
Which case should this code fulfill? gulp.src('files/folder/whatever.txt')
.pipe(gulp.dest('build')) Currently the answer is 1 as this seems to make the most sense. I'm open to discussion if we want to switch it, but I think using the dirname of the input file is not the most common case. It's easier for you to just do |
Haha :). I'm sorry @contra. Super clear now. Is just that is confusing to have different behavior for non-starred globs compared to the opposite. That is, having gulp.src(['files/folder/something.txt', 'files/**/whatever.txt'])
.pipe(gulp.dest('build')) Will result on
|
Just use the
As @contra said, the start of the glob is where the base is taken if not, it will match the path.basename, right? So yes @contra, I didn't understood what |
@stringparser Thank you for chiming in. You actually helped me look at this from a different prospective. Just like you, I was initially confused by the different behavior between the gulp.task "watch-less", ->
gulp.src "app/css/bootstrap-scoped.less",
base: 'app'
.pipe gulp.dest('.build') # file.relative correctly set to 'css/bootstrap-scoped.less'
return I suggest we capture this behavior under https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpsrcglobs-options, so it is clear for others as well. I can take a stab at writing a few sentences with @contra's blessing. |
glad that I was able to help @demisx :) I arrived to the same conclusion you write on your snippet. Be explicit about the base so even then you can make more than one write at the end. The last two links I left were when I understood why. I think a little bullet point on the |
I would love a PR to document this better. |
@demisx seems to be busy, if he doesn't take the lead I'll do it tomorrow ;) |
Sorry, I was able to get to it just this morning. @stringparser Please feel free to comment/edit. Writing docs is not my strongest skill. :) |
Very complete @demix. No worries is just that lately I've been having more time than usual haha. |
I have an issue with relative path being incorrectly calculated in
vinyl-fs
module used bygulp
. Please let me know if this should be entered undervinyl-fs
project instead.When I pass gulp.src a direct path string, the relative.path in
vinyl-fs/lib/dest/index.js
is set to the file name only, meaning it looses the directory prefix:However, if I pass a glob string instead of direct path, then the relative path is properly calculated and the directory prefix is present:
This is a contrived example just to show where the issue exists. In our gulp build, this result in files being written to the wrong directory.
The text was updated successfully, but these errors were encountered: