0

I'm trying to figure out how to pack a zip fille from a folder with a version suffix, but keep the original name of the folder when the archive is being extracted. It's a wp theme. So theme-1.5.0.zip must extract a folder named theme. But this code extracts it like theme-1.5.0

gulp.task('make-zip', function () {
  return gulp.src('build/theme/**')
  .pipe(zip('theme-'+version+'.zip'))
  .pipe(gulp.dest('build'))
});

When I compress theme folder manually in finder and then rename theme.zip to theme-1.5.0.zip it actually keeps the original name inside. But not if it was compressed with gulp.

Thanks!

1
  • So, I've removed my answer since doesn't add nothing to the response. About what you want. I don't know if you can do that, since, by default the uncompress folder takes the file name, unless the user, specifies otherwise. I'll keep an eye here to see if someone has a solution.
    – rmjoia
    Commented Jan 17, 2016 at 17:20

1 Answer 1

2

I ran into this issue myself. Ultimately I was able to get it work by setting a base path to the src.

gulp.task('make-zip', function () {
  return gulp.src('build/theme/**', {base: "build"})
  .pipe(zip('theme-'+version+'.zip'))
  .pipe(gulp.dest('build'))
});
1
  • One year later, I revisit this question of mine to find out that this is actually a correct answer.
    – Nikita
    Commented Mar 3, 2017 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.