tschaub / gulp-newer

Pass through newer source files only
https://npmjs.org/package/gulp-newer
226 stars 24 forks source link

Improve srcFile suffix replacement #9

Closed karlvr closed 9 years ago

karlvr commented 9 years ago

When using gulp.src, if you set a base dir then you can end up with relative paths that start with a ../.

The existing regex for replacing the file extension doesn't work in this case, even though the * is non-greedy.

We also perhaps need to consider what a file extension is. Is it the last part of the filename, delimited by the . or is it everything from the first . in the filename (not dirname) part of the path?

I've assumed the later in this suggested change to the regex. It matches . followed by anything not another . or a /, and then any other characters to the end of the string. Or just . at the end of the string.

karlvr commented 9 years ago

Thinking a little more deeply, perhaps the intention was to match the string after the final .. This would match the definition of the path extension in the Cocoa API (with which I'm familiar). Without this logic I have an issue with the jquery file jquery-1.10.2.js. So perhaps that regex should simply change to: /\.[^.]*$/

I'm happy to update the pull request if you agree!

Best, Karl

karlvr commented 9 years ago

Sure, that's a much better idea! I think we need a .length on the result of path.extname().

karlvr commented 9 years ago

I've pushed your change to this pull request, in case that makes it easier for you. Thanks for your super quick attention, it's awesome.

tschaub commented 9 years ago

Thanks for the enhancement @karlvr. Instead of debugging the Travis failure on Node 0.9, I'm inclined to update the .travis.yml to only test on Node 0.10. I'll handle that separately.