hparra / gulp-rename

Rename files easily
MIT License
692 stars 73 forks source link

Error: ENOENT: no such file or directory When Adding Question Mark to File Extension #92

Closed maks-humeniuk closed 4 years ago

maks-humeniuk commented 4 years ago

I spent around 4 hours to figure out that Error: ENOENT: no such file or directory is caused by adding ? to file extension, however # works.

Example:

src('./dist/src/script.js')
  .pipe(rename('script.js?t=1592490407282'))
  .pipe(dest('./dist/src/'));

I'm trying to bust cache with this approach, and I can't modify basename, because it'll change file name, hence code, which requests file, won't find it. So, instead of script.1592490407282.js I need script.js?t=1592490407282, because it's pretty much the same as script.js, at least it was so for a long time and usually used to bust favicon cache.

maks-humeniuk commented 4 years ago

It seems that I confused changing file name with its URL. So, something like src="/path/to/script.js?t=1592490407282" would work, while renaming script.js to script.js?t=1592490407282 won't, at least on Windows.