<commit_before>/***
 * Copyright (c) 2016 <NAME> (@localnerve), LocalNerve LLC
 * Copyrights licensed under the BSD License. See the accompanying LICENSE file for terms.
 */
/* global Set */
import path from 'path';
import gulpNodemon from 'gulp-nodemon';

/**
 * Factory for the nodemon task.
 *
 * @param {Object} settings - The project settings.
 * @param {String} target - One of ['dev', 'debug', 'perf', 'prod'].
 * @returns {Function} The nodemon task.
 */
export default function nodemonTaskFactory (settings, target) {
  const options = {
    ignore: [
      settings.src.serviceWorker.data,
      settings.src.serviceWorker.precache,
      settings.src.assetsJson,
      settings.src.assetsRevManifest
    ],
    ignoreRoot: [
      'build',
      'tests',
      'node_modules/application/'
    ],
    ext: 'js jsx scss',
    watch: settings.src.baseDir,
    tasks: (changedFiles) => {
      const buildTarget = target === 'debug' ? 'dev' : target;
      const tasks = new Set();

      changedFiles.forEach((file) => {
        if (/\.js.?$/.test(file)) {
          if (/\/sw\/?/.test(path.dirname(file))) {
            tasks.add(`bundlesSw_${buildTarget}`);
          } else {
            tasks.add(`bundlesMain_${buildTarget}`);
          }
        } else {
          // Must be scss
          tasks.add(`ccss_${buildTarget}`);
        }
      });

      return Array.from(tasks);
    }
  };

  if (target === 'debug') {
    options.nodeArgs = ['--debug-brk'];
  }

  return function nodemon (done) {
    gulpNodemon(options);
    done();
  }
}<commit_msg>fix #217, nodemon legacy watch for osx<commit_after>/***
 * Copyright (c) 2016 <NAME> (@localnerve), LocalNerve LLC
 * Copyrights licensed under the BSD License. See the accompanying LICENSE file for terms.
 */
/* global Set */
import path from 'path';
import gulpNodemon from 'gulp-nodemon';

/**
 * Factory for the nodemon task.
 *
 * @param {Object} settings - The project settings.
 * @param {String} target - One of ['dev', 'debug', 'perf', 'prod'].
 * @returns {Function} The nodemon task.
 */
export default function nodemonTaskFactory (settings, target) {
  const legacyWatchOptions = {
    legacyWatch: true,
    pollingInterval: 250
  };

  const options = {
    ignore: [
      settings.src.serviceWorker.data,
      settings.src.serviceWorker.precache,
      settings.src.assetsJson,
      settings.src.assetsRevManifest
    ],
    ignoreRoot: [
      'build',
      'tests',
      'node_modules/application'
    ],
    verbose: true,
    ext: 'js jsx scss',
    watch: settings.src.baseDir,
    tasks: (changedFiles) => {
      const buildTarget = target === 'debug' ? 'dev' : target;
      const tasks = new Set();

      changedFiles.forEach((file) => {
        if (/\.js.?$/.test(file)) {
          if (/\/sw\/?/.test(path.dirname(file))) {
            tasks.add(`bundlesSw_${buildTarget}`);
          } else {
            tasks.add(`bundlesMain_${buildTarget}`);
          }
        } else {
          // Must be scss
          tasks.add(`ccss_${buildTarget}`);
        }
      });

      return Array.from(tasks);
    }
  };

  // This is a workaround for an OSX/chokidar issue I'm experiencing (#217)
  if (process.platform === 'darwin') {
    Object.assign(options, legacyWatchOptions);
  }

  if (target === 'debug') {
    options.nodeArgs = ['--debug-brk'];
  }

  return function nodemon (done) {
    gulpNodemon(options);
    done();
  }
}
{'fraction_non_alphanumeric': 0.15335276967930028, 'fraction_numerical': 0.004956268221574344, 'mean_word_length': 2.472672064777328, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7619134', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1062, 'n_words': 264}