hparra / gulp-rename

Rename files easily
MIT License
692 stars 73 forks source link

suffix option does not respect "multiple" extensions #16

Closed gberger closed 6 years ago

gberger commented 10 years ago
// abc.min.js
rename({suffix: '-v2.0.1'})
// abc.min-v2.0.1.js

I expected it to be abc-v2.0.1.min.js.

Is there an easy way to do this, or would I need to use a custom function?

hparra commented 10 years ago

I would recommend the custom function for now. I'll keep this open while I evaluate the expected behavior.

mhelvens commented 10 years ago

I've run into this problem too. What about an option:

rename(<fn|obj>, { multiExt: true })

This should then start the extension at the first dot in the filename rather than the last.

mhelvens commented 10 years ago

Alternatively, counterparts of the available options/fields:

rename({ suffixL: '-v2.0.1' }) // does what gberger wants
rename(function (fileObj) {
    console.log(fileObj.basename , fileObj.extname ); // 'abc.min', '.js'
    console.log(fileObj.basenameL, fileObj.extnameL); // 'abc', '.min.js'
})

I'm not sure which solution is nicer.

UltCombo commented 9 years ago

Perhaps an extFirstDot boolean option, which defaults to false for back-compat.

pgayvallet commented 9 years ago

Had the same issues for my "*.js.map" files.

Imangazaliev commented 8 years ago

Please add extDot option such as in Grunt: http://gruntjs.com/configuring-tasks