<commit_before>const spawn = require('child_process').spawn;
let buildProcesses = [];

var watcher = require('chokidar').watch([
  'src/**'
], {
  persistent: true,
  ignoreInitial: true,
  ignored: [
    // all generated files need to be ignored
    'src/extension/features/index.js',
    'src/core/settings/settings.js',
    'src/**/feedChanges.js'
  ]
});

watcher.on('all', function (event, path) {
  console.log(`Changes detected (${path}), rebuilding...`);

  if (buildProcesses.length) {
    buildProcesses.forEach(proc => proc.kill());
  }

  spawnBuildProcess();
});

function spawnBuildProcess() {
  const buildProcess = spawn('yarn build', {
    stdio: [0, 1, 2]
  });

  buildProcess.on('close', (data) => {
    if (data !== 0 && data !== null) {
      console.log('Process exited with non-zero, retrying...');
      spawnBuildProcess();
    }

    buildProcesses.splice(buildProcesses.indexOf(buildProcess), 1);
  });

  buildProcesses.push(buildProcess);
}<commit_msg>Update watch script to work on windows<commit_after>const spawn = require('child_process').spawn;
let buildProcesses = [];

var watcher = require('chokidar').watch([
  'src/**'
], {
  persistent: true,
  ignoreInitial: true,
  ignored: [
    // all generated files need to be ignored
    'src/extension/features/index.js',
    'src/core/settings/settings.js',
    'src/**/feedChanges.js'
  ]
});

watcher.on('all', function (event, path) {
  console.log(`Changes detected (${path}), rebuilding...`);

  if (buildProcesses.length) {
    buildProcesses.forEach(proc => proc.kill());
  }

  spawnBuildProcess();
});

function spawnBuildProcess() {
  const yarnCLI = /^win/.test(process.platform) ? 'yarn.cmd' : 'yarn';
  const buildProcess = spawn(yarnCLI, ['build'], {
    stdio: [0, 1, 2]
  });

  buildProcess.on('close', (data) => {
    if (data !== 0 && data !== null) {
      console.log('Process exited with non-zero, retrying...');
      spawnBuildProcess();
    }

    buildProcesses.splice(buildProcesses.indexOf(buildProcess), 1);
  });

  buildProcesses.push(buildProcess);
}

spawnBuildProcess();
{'fraction_non_alphanumeric': 0.17911877394636017, 'fraction_numerical': 0.004789272030651341, 'mean_word_length': 3.769406392694064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3551362', 'n_tokens_mistral': 696, 'n_tokens_neox': 679, 'n_words': 138}