Search code examples
javascriptnode.jsgulp

gulp.src base option apply on one array item


I'm using the base option in my gulp.src
I want the base will apply on one item in my src array but not in rest:
In my case:

   gulp.src(['./languages/*.json', '../../../Configuration/Client/help/*/**'],{base:'../../../Configuration/Client'})
                .pipe(zip('my_zip_file.zip'))
                .pipe(gulp.dest('./dist/'));

I need that {base:'../../../Configuration/Client'} will apply only on second item in the array ('../../../Configuration/Client/help/*/**') and not on the first item.

It's seems like the base option cannot be separated per array item.


Solution

  • Add the following to your npm package: event-stream

    Then in your gulpfile.js:

      var eventStream = require('event-stream');
      var jsonFiles = gulp.src('./languages/*.json');
      var helpfiles = gulp.src('../../../Configuration/Client/help/*/**',{base:'../../../Configuration/Client'});
    
      eventStream.merge(jsonFiles,helpfiles)
          .pipe(zip('myZipFile.zip'))
          .pipe(gulp.dest('./languages/'))