<commit_before>'use strict';

var gulp = require( 'gulp' );
var $ = require( 'gulp-load-plugins' )();
var config = require( '../config' ).copy;
var handleErrors = require( '../utils/handleErrors' );
var browserSync = require( 'browser-sync' );

gulp.task( 'copy:files', function() {
  return gulp.src( config.files.src )
    .pipe( $.changed( config.files.dest ) )
    .on( 'error', handleErrors )
    .pipe( gulp.dest( config.files.dest ) )
    .pipe( browserSync.reload( {
      stream: true
    } ) );
} );

gulp.task( 'copy:legacy', function() {
  return gulp.src( config.legacy.src )
    .pipe( $.changed( config.legacy.dest ) )
    .on( 'error', handleErrors )
    .pipe( gulp.dest( config.legacy.dest ) )
    .pipe( browserSync.reload( {
      stream: true
    } ) );
} );

gulp.task( 'copy:icons', function() {
  return gulp.src( config.icons.src )
    .pipe( $.changed( config.icons.dest ) )
    .on( 'error', handleErrors )
    .pipe( gulp.dest( config.icons.dest ) )
    .pipe( browserSync.reload( {
      stream: true
    } ) );
} );

gulp.task( 'copy:vendorfonts', function() {
  return gulp.src( config.vendorfonts.src )
    .pipe( $.changed( config.vendorfonts.dest ) )
    .on( 'error', handleErrors )
    .pipe( gulp.dest( config.vendorfonts.dest ) )
    .pipe( browserSync.reload( {
      stream: true
    } ) );
} );

gulp.task( 'copy:vendorcss', function() {
  return gulp.src( config.vendorcss.src )
    .pipe( $.changed( config.vendorcss.dest ) )
    .on( 'error', handleErrors )
    .pipe( $.replace(
      /url\(".\/ajax-loader.gif"\)/ig,
      'url("/static/img/ajax-loader.gif")'
    ) )
    .pipe( gulp.dest( config.vendorcss.dest ) )
    .pipe( browserSync.reload( {
      stream: true
    } ) );
} );

gulp.task( 'copy:vendorimg', function() {
  return gulp.src( config.vendorimg.src )
    .pipe( $.changed( config.vendorimg.dest ) )
    .on( 'error', handleErrors )
    .pipe( gulp.dest( config.vendorimg.dest ) )
    .pipe( browserSync.reload( {
      stream: true
    } ) );
} );

gulp.task( 'copy:vendorjs', function() {
  return gulp.src( config.vendorjs.src )
    .pipe( $.changed( config.vendorjs.dest ) )
    .on( 'error', handleErrors )
    .pipe( gulp.dest( config.vendorjs.dest ) )
    .pipe( browserSync.reload( {
      stream: true
    } ) );
} );

gulp.task( 'copy',
  [
    'copy:files',
    'copy:legacy',
    'copy:icons',
    'copy:vendorfonts',
    'copy:vendorcss',
    'copy:vendorimg',
    'copy:vendorjs'
  ]
);<commit_msg>Consolidates redundant copy code<commit_after>'use strict';

var gulp = require( 'gulp' );
var $ = require( 'gulp-load-plugins' )();
var config = require( '../config' ).copy;
var handleErrors = require( '../utils/handleErrors' );
var browserSync = require( 'browser-sync' );

/**
 * Generic copy files flow from source to destination.
 * @param {string} src The path to the source files.
 * @param {string} dest The path to destination.
 * @returns {Object} An output stream from gulp.
 */
function _genericCopy( src, dest ) {
  return gulp.src( src )
    .pipe( $.changed( dest ) )
    .on( 'error', handleErrors )
    .pipe( gulp.dest( dest ) )
    .pipe( browserSync.reload( {
      stream: true
    } ) );
}

gulp.task( 'copy:files', function() {
  return _genericCopy( config.files.src, config.files.dest );
} );

gulp.task( 'copy:legacy', function() {
  return _genericCopy( config.legacy.src, config.legacy.dest );
} );

gulp.task( 'copy:icons', function() {
  return _genericCopy( config.icons.src, config.icons.dest );
} );

gulp.task( 'copy:vendorfonts', function() {
  return _genericCopy( config.vendorfonts.src, config.vendorfonts.dest );
} );

gulp.task( 'copy:vendorcss', function() {
  return gulp.src( config.vendorcss.src )
    .pipe( $.changed( config.vendorcss.dest ) )
    .on( 'error', handleErrors )
    .pipe( $.replace(
      /url\(".\/ajax-loader.gif"\)/ig,
      'url("/static/img/ajax-loader.gif")'
    ) )
    .pipe( gulp.dest( config.vendorcss.dest ) )
    .pipe( browserSync.reload( {
      stream: true
    } ) );
} );

gulp.task( 'copy:vendorimg', function() {
  return _genericCopy( config.vendorimg.src, config.vendorimg.dest );
} );

gulp.task( 'copy:vendorjs', function() {
  return _genericCopy( config.vendorjs.src, config.vendorjs.dest );
} );

gulp.task( 'copy',
  [
    'copy:files',
    'copy:legacy',
    'copy:icons',
    'copy:vendorfonts',
    'copy:vendorcss',
    'copy:vendorimg',
    'copy:vendorjs'
  ]
);
{'fraction_non_alphanumeric': 0.1838898916967509, 'fraction_numerical': 0.0, 'mean_word_length': 3.008137432188065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4395619', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1560, 'n_words': 318}