Skip to content
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

Base for gulp.src is empty if working directory has braces #1744

Closed
sydorivskyi opened this issue Aug 3, 2016 · 11 comments
Closed

Base for gulp.src is empty if working directory has braces #1744

sydorivskyi opened this issue Aug 3, 2016 · 11 comments

Comments

@sydorivskyi
Copy link

sydorivskyi commented Aug 3, 2016

Relative gulp version: 4

Create any directory with brackets i.e "gulp (brackets)"

  • create readme.md file
  • create simple gulpfile
const gulp = require('gulp');

gulp.task('default', function () {
  return gulp.src('readme.md')
    .pipe(gulp.dest('dist'));
})
  • run gulp

Actual result:
In directory dest we can see readme.md inside "gulp (brackets)" directory

Expected result:
In directory dest we can see readme.md file

@heikki
Copy link
Contributor

heikki commented Aug 14, 2016

@phated
Copy link
Member

phated commented Aug 15, 2016

Are parentheses generally valid in filenames? Does this fall into a glob issue? I wonder if they use parens as a special character.

@stephenlacy
Copy link
Contributor

stephenlacy commented Aug 18, 2016

Tested latest glob and glob-stream, both return the folder cwd path correctly.

https://github.com/stevelacy/glob-parens-test

selection_0482016dt

@phated
Copy link
Member

phated commented Aug 23, 2016

@stevelacy does it work with a space between gulp and the first paren?

@stephenlacy
Copy link
Contributor

The output from glob-stream:

``
{
cwd: '/home/sl/Projects/node/glob-parens-test (parens)',
base: '/home/sl/Projects/node/',
path: '/home/sl/Projects/node/glob-parens-test (parens)/folder/gulp (brackets)/readme.md'}

@phated
Copy link
Member

phated commented Aug 23, 2016

Thanks @stevelacy - I'm really confused about this then. @heikki did you confirm that it's a problem or just create the repo?

@heikki
Copy link
Contributor

heikki commented Aug 23, 2016

@phated repo task creates gulp (brackets) dir like in the issue description, I didn't debug it further

@lukaskostial
Copy link

I'm having the same issue on Windows as our Jenkins in located in C:\Program Files (x86)\jenkins and it seems that base is evaluated to C:\ so gulp.dest then creates the full path in the destination folder (Program Files (x86)\jenkins..... ).

But it seems like glob issue. Check the base of the @stevelacy test with and without brackets in the folder name:
screen shot 2016-08-23 at 14 40 40

@lukaskostial
Copy link

lukaskostial commented Aug 23, 2016

It seems that it is caused by isGlob and globParent implementation where isGlob evaluates such folder name as glob...

// From is-glob
module.exports = function isGlob(str) {
  return typeof str === 'string'
    && (/[*!?{}(|)[\]]/.test(str)
     || isExtglob(str));
};

// From glob-parent
module.exports = function globParent(str) {
    str += 'a'; // preserves full path in case of trailing path separator
    do {str = path.dirname(str)} while (isglob(str));
    return str;
};

// From glob-stream :
var basePath = opt.base || globParent(ourGlob) + path.sep;

@doowb
Copy link
Member

doowb commented Aug 23, 2016

I did a PR to glob-stream that basically changes when the basePath is calculated to only check against the passed in glob.

This passes all the current tests and writes the readme to the correct location in the example repo.

@phated
Copy link
Member

phated commented Aug 23, 2016

Thanks to the debugging by @lukaskostial / @heikki / @stevelacy and great work by @doowb this has been fixed in v5.3.3 of glob-stream

phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 16, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 16, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 16, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 16, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 20, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 21, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 21, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 21, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 21, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 21, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 21, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 21, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 21, 2017
phated pushed a commit to gulpjs/glob-stream that referenced this issue Feb 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants