hparra / gulp-rename

Rename files easily
MIT License
692 stars 73 forks source link

feat(path): add support for changing path #12

Closed rovjuvano closed 10 years ago

rovjuvano commented 10 years ago

Current behavior

Only the filename/path relative to base can be changed. Specifying a new name which includes a path moves the file into a subdirectory relative to base.

Given: "test/fixtures/hello.txt" and rename("test/elsewhere/hello.txt") results in "test/fixtures/test/elsewhere/hello.txt"

Hacking with '..' such as rename("../elsewhere/hello.txt") results in path.join(file.base, file.cwd, "test/elsewhere/hello.txt")

When called as rename(function(dir, base, ext) {...}), dir cannot be modified while base and ext can.

Desired behavior

Support for modifying the relative path from CWD. Specifying a new name which includes a path moves the file into a subdirectory relative to CWD.

Given: "test/fixtures/hello.txt" and rename("test/elsewhere/hello.txt") results in "test/elsewhere/hello.txt"

When called as rename(function(dir, base, ext) {...}), dir can be modified along with base and ext.

Other

I bumped the version in a separate commit. Feel free to ignore.

rovjuvano commented 10 years ago

Closing. While the unit tests pass, it doesn't handle real uses cases properly. The way the plugin handles globs and relatives paths needs reworked to be consistent with gulp.src and gulp.dest. Pull request coming.