cgross / gulp-dom-src

Create a gulp stream from script, link, or any set of tags in an HTML file.
MIT License
41 stars 8 forks source link

Writeable stream interface #2

Closed psalaets closed 9 years ago

psalaets commented 9 years ago

Is there any way for gulp-dom-src to be writeable? I am generating html which I want to pipe into gulp-dom-src to scan for script tags.

Right now I am doing

gulp.task('processScripts', function(cb) {
  var generateHtml = gulp.src(pathToTemplates)
    .pipe(evalTemplates())
    .pipe(gulp.dest(destDir));

  generateHtml.on('end', function() {
    var processScripts = gulpDomSrc({
      file: destDir + 'index.html',
      selector: 'script'
      attribute: 'src'
    })
    .pipe(processJsFiles())
    .pipe(gulp.dest(...);

    processScripts.on('end', cb);
  });
});

I use events to order things properly and write/read disk an extra time.

I wish I could do

gulp.task('processScripts', function() {
  return gulp.src(pathToTemplates)
    .pipe(evalTemplates())
    .pipe(gulpDomSrc.writeable({ // <-- this would be new
      selector: 'script'
      attribute: 'src'
    })
    .pipe(processJsFiles())
    .pipe(gulp.dest(...);
});

Would you be open to a PR that implemented something like the latter example?

cgross commented 9 years ago

Yea definitely. I'll happily look at any PR that implements something like this.

psalaets commented 9 years ago

Thanks

demisx commented 7 years ago

Would be great if there was a quick example in readme on how to use this feature.