urish / gulp-add-src

Add more 'src' files at any point in the pipeline (gulp plugin)
86 stars 8 forks source link

Deprecate? #1

Closed sindresorhus closed 10 years ago

sindresorhus commented 10 years ago

gulp 3.8 now supports adding files midstream which makes this plugin moot. You might want to consider deprecating it ;)

urish commented 10 years ago

I would appreciate it if you could send a pull request with the required changes to deprecate the module. Thanks!

sindresorhus commented 10 years ago

I can't deprecate it. You do:

npm deprecate gulp-add-src 'This is no longer needed. Use gulp.src instead'
urish commented 10 years ago

Done! Thanks for providing the instructions :-)

sindresorhus commented 10 years ago

A notice about it being deprecated in the readme is also useful ;)

kentcdodds commented 10 years ago

:+1: on noting it in the readme... I've added this to a few projects until I finally saw the note in the npm install output...

However, when trying to switch to using gulp.src, it's not quite working properly. I'm getting a Error: write after end when I switch. Perhaps it has something to do with something else in my pipeline? But everything seems to be working when I use gulp-add-src... So I think I'll keep using it unless you can point out something I'm doing wrong in my pipeline:

// note, I'm using gulp-load-plugins
// in a function where vendorFiles is an object with an array of filepath strings called js
var vendorScripts = vendorFiles.js;
var filterHtml = plugins.filter('**/*.html');
gulp.src(paths.myJS)

  // jshint
  .once('data', startTimer('jshint'))
  .pipe(plugins.jshint())
  .pipe(plugins.jshint.reporter('jshint-stylish'))
  .pipe(plugins.jshint.reporter('fail'))
  .pipe(timers.jshint)

  .pipe(plugins.addSrc(paths.myHtml))
  .pipe(filterHtml)

  // ng-template-cache
  .once('data', startTimer('ng-template-cache'))
  .pipe(plugins.minifyHtml({
    empty: true,
    conditionals: true
  }))
  .pipe(plugins.angularTemplatecache({
    root: '/',
    base: function(file) {
      return path.join(path.relative('./app', file.base), file.relative);
    },
    module: angularModuleName
  }))
  .pipe(timers['ng-template-cache'])

  .pipe(filterHtml.restore())
  .pipe(gulp.src(vendorScripts)) // Changing this line to plugins.addSrc(vendorScripts) makes everything work.

  // ng-annotate
  .once('data', startTimer('ng-annotate'))
  .pipe(plugins.ngAnnotate())
  .pipe(timers['ng-annotate'])

  .pipe(plugins.order(vendorScripts.concat('**/*.module.js'), { base: '.' }))

  // concat
  .once('data', startTimer('js-concat'))
  .pipe(plugins.concat('script.js'))
  .pipe(timers['js-concat'])

  // uglify
  .once('data', startTimer('js-uglify'))
  .pipe(plugins.uglify())
  .pipe(timers['js-uglify'])

  .pipe(gulp.dest(path.join(paths.prod, '/scripts')))
  .once('end', pipeDone('js', done));

Also, if I put a .pipe(plugins.print()) right after the pipe(gulp.src(vendorScripts)) it appears that my pipeline has been replaced by the vendorScripts rather than vendorScripts being added to my pipeline.

Am I doing something wrong? Or should this not have been deprecated? I do think that I'm doing some unconventional things by not having this split out into separate tasks, but I prefer to not have a .tmp directory :-)

Anyway, I'll keep using this plugin unless I can find a way to make gulp.src to work with my setup.

kelsin commented 10 years ago

I was trying to remove gulp-add-src this morning after seeing the deprecation notice but for me, only some of my files were being added. Like @kentcdodds I was adding an array of files halfway through the pipe.

My task:

gulp.task('js', function() {
    gulp.src(templates)
        .pipe(emberTemplates())
        .pipe(concat('templates.js'))
        .pipe(gulp.src(js))
        .pipe(sourcemaps.init())
        .pipe(concat('app.js'))
        .pipe(uglify())
        .pipe(sourcemaps.write('maps'))
        .pipe(gulp.dest('dist/js'));
});

my js variable:

var js = [
    'app/app.js',
    'app/router.js',
    'app/controllers/**/*.js',
    'app/routes/**/*.js'];

For me it was adding the first two and ignoring the two globs. Could this be a bug in gulp.src? This code is currently working perfectly if I use gulp-add-src instead of gulp.src halfway through the pipe.

lehni commented 8 years ago

I wonder if it was right to deprecate this plugin just yet. It looks like it covers use cases that gulp.src() since 3.8.0 does not cover, see: https://github.com/gulpjs/gulp/issues/1508