<commit_before>module.exports = function(appData) {

  const gulp         = appData.gulp,
        changed      = require('gulp-changed'),
        merge        = require('merge-stream');


  appData.tasks.customDirs = {
    run: function(taskData) {

      taskData = taskData || { isWatch: false, dirInfos: appData.dirs.custom };
      if (!taskData.dirInfos) {
        taskData.dirInfos = appData.dirs.custom;
      }

      var streams = [];

      var injector = new appData.Injector('customDirs', appData, taskData);
      
      var dirInfos = injector.run('init', taskData.dirInfos);
      if (injector.isTaskCanceled(dirInfos)) {
        return Promise.resolve();
      }

      for (var dirName in dirInfos) {
        if (!dirInfos.hasOwnProperty(dirName))
          continue;

        var dirInfo = dirInfos[dirName];

        var injectorDir = new appData.Injector(dirInfo, appData, taskData);

        //data passed to injector as a second parameter
        var injectorData = { id: dirName, dirInfo: dirInfo };

        var stream = injectorDir.run('src', null, injectorData );
        if (injectorDir.isTaskCanceled(stream)) {
          continue;
        }

        if (dirInfo.to !== null) {
          if (!injector.isCanceled) {
            stream = gulp.src(appData.app.sanitizeGlob(stream ? stream : dirInfo.from));
          }
          stream = injectorDir.run('limit', stream, injectorData);
          if (!injector.isCanceled) {
            stream = stream.pipe(changed(dirInfo.to));
          }
          stream = injectorDir.run('dest', stream, injectorData);
          if (!injector.isCanceled) {
            stream = stream.pipe(gulp.dest(dirInfo.to));
          }

          streams.push(stream);
        }
      }

      injector.run('finish', streams, { dirInfos: dirInfos });

      if (streams.length) {
        var promise = appData.app.streamToPromise(merge.apply(merge, streams));
        promise.then(() => {
          injector.run('reload');
          if (!injector.isCanceled) {
            if (taskData.isWatch) {
              appData.browserSync.reload();
            }
          }
        });
        return promise;
      }
      else {
        return Promise.resolve();
      }
    }
  }
}<commit_msg>custom dirs reload fix<commit_after>module.exports = function(appData) {

  const gulp         = appData.gulp,
        changed      = require('gulp-changed'),
        merge        = require('merge-stream');


  appData.tasks.customDirs = {
    run: function(taskData) {

      taskData = taskData || { isWatch: false, dirInfos: appData.dirs.custom };
      if (!taskData.dirInfos) {
        taskData.dirInfos = appData.dirs.custom;
      }

      var streams = [];

      var injector = new appData.Injector('customDirs', appData, taskData);
      
      var dirInfos = injector.run('init', taskData.dirInfos);
      if (injector.isTaskCanceled(dirInfos)) {
        return Promise.resolve();
      }

      for (var dirName in dirInfos) {
        if (!dirInfos.hasOwnProperty(dirName))
          continue;

        var dirInfo = dirInfos[dirName];

        var injectorDir = new appData.Injector(dirInfo, appData, taskData);

        //data passed to injector as a second parameter
        var injectorData = { id: dirName, dirInfo: dirInfo };

        var stream = injectorDir.run('src', null, injectorData );
        if (injectorDir.isTaskCanceled(stream)) {
          continue;
        }

        if (dirInfo.to !== null) {
          if (!injector.isCanceled) {
            stream = gulp.src(appData.app.sanitizeGlob(stream ? stream : dirInfo.from));
          }
          stream = injectorDir.run('limit', stream, injectorData);
          if (!injector.isCanceled) {
            stream = stream.pipe(changed(dirInfo.to));
          }
          stream = injectorDir.run('dest', stream, injectorData);
          if (!injector.isCanceled) {
            stream = stream.pipe(gulp.dest(dirInfo.to));
          }

          streams.push(stream);
        }
      }

      injector.run('finish', streams, { dirInfos: dirInfos });

      var promise;
      if (streams.length) {
        promise = appData.app.streamToPromise(merge.apply(merge, streams));
      }
      else {
        promise = Promise.resolve();
      }

      promise.then(() => {
        injector.run('reload');
        if (!injector.isCanceled) {
          if (taskData.isWatch) {
            appData.browserSync.reload();
          }
        }
      });

      return promise;
    }
  }
}
{'fraction_non_alphanumeric': 0.12541694462975317, 'fraction_numerical': 0.0, 'mean_word_length': 1.9986666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1169406', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1358, 'n_words': 254}