gulpjs / glob-stream

Readable streamx interface over anymatch.
MIT License
178 stars 53 forks source link

Add cwdbase option to enable file base to match cwd. #11

Closed azweb76 closed 10 years ago

azweb76 commented 10 years ago

By setting cwdbase: true, all files returned from glob will have a relative path being relative to the cwd. This is useful if you want perform operations on multiple directories relative to the cwd and not relative to the lowest glob expression.

Example: gulp.src(["lib/", "bin/"], { cwd: process.cwd, cwdbase: true }).pipe(gulp.dest("/mydest/"));

This will result in /mydest/lib/ and /mydest/bin/ compared to /mydest/

yocontra commented 10 years ago

Wouldn't something like base: process.cwd() make more sense?

azweb76 commented 10 years ago

That is what I started, however the code uses cwd to make unrelative. I can change to base if you'd prefer.

azweb76 commented 10 years ago

Since the code defaults the common path to cwd, I felt this would make sense.

yocontra commented 10 years ago

Will look at this more when I get to a PC tonight

azweb76 commented 10 years ago

Sweet. Thanks for being so prompt.

azweb76 commented 10 years ago

Also noticed that if I add "/mydir//test/", the base is set to /mydir/test/. I think the logic for detecting the base needs more thought. Should probably stop the flatten2d at the first non-string.

azweb76 commented 10 years ago

I can change if you'd like.

yocontra commented 10 years ago

@azweb76 it should stop it at the first non-string. i'm always open to PRs that add more tests (failing or passing)

yocontra commented 10 years ago

@azweb76 the glob basePath issue is fixed as of glob2base 0.0.3