hparra / gulp-rename

Rename files easily
MIT License
692 stars 73 forks source link

question: not renaming, just copying? #53

Closed ghost23 closed 9 years ago

ghost23 commented 9 years ago

Hi,

I am probably missing something here. gulp-rename is not renaming my file, but merely copying it with a new name.

This is what I do:

gulp.src("./dev/out/css/main.css") .pipe(rename("main_something.css")) .pipe(gulp.dest("./dev/out/css/"));

Running this, I end up with the main.css AND the main_something.css file.

misteroh commented 9 years ago

This plugin doesn't delete the src file: https://github.com/hparra/gulp-rename/issues/34

Please refer to this link in order to delete the src file https://github.com/gulpjs/gulp/blob/master/docs/recipes/delete-files-folder.md#delete-files-in-a-pipeline

ghost23 commented 9 years ago

Oh, I see.

wembernard commented 8 years ago

Cannot agree more with @ghost23. This plugin name is misleading. Should be called gulp-copy instead of gulp-rename imho.

yocontra commented 8 years ago

No, it shouldn't be called gulp-copy. It's called gulp-rename because it renames an in-memory gulp file object. gulp is like functional programming, each plugin takes in input and produces output in-memory without causing side effects.

wembernard commented 8 years ago

I see your point. Then maybe a simple optional parameter such as deleteOrigin: true (false by default) would be a nice compromise?

shinnn commented 8 years ago

@wembernard We'll never add it. deleteOrigin option violates the plugin guideline.

Your plugin should only do one thing, and do it well.

yocontra commented 7 years ago

@hudsonfoo gulp works like this:

Plugins aren't allowed to touch the fs, the user is responsible for writing changes back to the fs using gulp.dest or any other vinyl adapter. Adding a flag that makes this plugin touch the fs is never going to happen because it violates the whole paradigm of what plugins are supposed to do.

Couple of options:

// rimraf = gulp-rimraf
src('folder/file.js')
  .pipe(rimraf()) // delete the original disk copy
  .pipe(rename('someting.js')) // rename the file
  .pipe(dest('folder')) // write back to disk
// vinylPaths = vinyl-paths, del = del
src('folder/file.js')
  .pipe(vinylPaths(del)) // delete the original disk copy
  .pipe(rename('someting.js')) // rename the file
  .pipe(dest('folder')) // write back to disk
wembernard commented 7 years ago

Thanks for sharing this. It might be interesting to add this to the Readme.md for plugin users to be informed and warned about the "How it's intended to be used" which seems to not be intuitive for everyone.

And, if I may, your paradigm (which btw is the https://en.wikipedia.org/wiki/Unix_philosophy), didn't stop Unix to develop mv which is somewhat a cp + rm combined and is (sometimes) used to "rename" :)

And this may be why people feel confused about the way this plugin work and may feel it's counter-intuitive ;)

Therealskythe commented 4 years ago

4 years later and people like me are still wasting time because the name of this module makes them think it renames files instead of copying them.

And no, renaming an object does not leave you with two. Not in real life, and not when dealing with digital objects like files or folders. Basically what wembernard said in 2016.

yocontra commented 4 years ago

If you would like to contribute some changes to the README that make it less confusing please feel free to send a PR - documentation changes are very helpful and easy to merge.

FWIW I'm not the author of this package but I do have merge/publish rights to it.

Mr-Wallet commented 1 year ago

Just ran into this problem myself... I was trying to make a quick change to a pipeline and thought it was renaming a file because the README says, "gulp-rename is a gulp plugin to rename files easily."

OK, good, it renames files which is exactly what the name implies... no caveats about vinyl anywhere. 👍 I guess I was paranoid for even checking but y'know, it's gulp so I wasn't sure.

Then the build system broke and I needed to find #34 for clarification.