<commit_before>// call it as `$ node scripts/update-examples.js` from root
const join = require('path').join;
const existsSync = require('fs').existsSync;
const spawn = require('child_process').spawn;
const execSync = require('child_process').execSync;
const rimrafSync = require('rimraf').sync;

const examples = [
  'browser-less',
  'browser-ts',
  'browser-ts-react',
  'browser-ts-react-i18n',
  'spa-ts',
  'spa-ts-i18n',
  'node-ts'
];

const stdio = 'inherit';

examples.forEach(example => {
  console.log(`Update "${example}":`);
  try {
    // fresh start
    const cwd = join(process.cwd(), 'examples', example);
    rimrafSync(join(cwd, 'node_modules'));
    rimrafSync(join(cwd, 'dist'));
    rimrafSync(join(cwd, 'dist-tests'));
    rimrafSync(join(cwd, 'dist-release'));
    execSync('npm install', { cwd, stdio });

    // test commands
    execSync('npm run -s ws -- build', { cwd, stdio });
    if (example.includes('spa')) {
      execSync('npm run -s ws -- build --production', { cwd, stdio });
    }
    execSync('npm run -s ws -- lint', { cwd, stdio });
    if (
      existsSync(join(cwd, 'tests', 'unit.ts')) ||
      existsSync(join(cwd, 'tests', 'unit.js')) ||
      existsSync(join(cwd, 'tests', 'unit.tsx'))
    ) {
      execSync('npm run -s ws -- unit', { cwd, stdio });
    }
    // test grid
    if (example === 'spa-ts') {
      const server = spawn('npm', [ 'run', '-s', 'ws', '--', 'serve'], { cwd, detached: true });
      execSync('npm run -s ws -- e2e --browsers ff', { cwd, stdio });
      // execSync('npm run -s ws -- e2e -g', { cwd, stdio });
      // execSync('npm run -s ws -- unit -g', { cwd, stdio });
      server.kill();
    }
  } catch (err) {
     throw `[ERROR] Couldn't update "${example}"!`;
  }
  console.log(`Finished updating "${example}".`);
});

console.log('Updated all examples ♥');<commit_msg>fix travis e2e build<commit_after>// call it as `$ node scripts/update-examples.js` from root
const join = require('path').join;
const existsSync = require('fs').existsSync;
const spawn = require('child_process').spawn;
const execSync = require('child_process').execSync;
const rimrafSync = require('rimraf').sync;

const examples = [
  'browser-less',
  'browser-ts',
  'browser-ts-react',
  'browser-ts-react-i18n',
  'spa-ts',
  'spa-ts-i18n',
  'node-ts'
];

const stdio = 'inherit';

examples.forEach(example => {
  console.log(`Update "${example}":`);
  try {
    // fresh start
    const cwd = join(process.cwd(), 'examples', example);
    rimrafSync(join(cwd, 'node_modules'));
    rimrafSync(join(cwd, 'dist'));
    rimrafSync(join(cwd, 'dist-tests'));
    rimrafSync(join(cwd, 'dist-release'));
    execSync('npm install', { cwd, stdio });

    // test commands
    execSync('npm run -s ws -- build', { cwd, stdio });
    if (example.includes('spa')) {
      execSync('npm run -s ws -- build --production', { cwd, stdio });
    }
    execSync('npm run -s ws -- lint', { cwd, stdio });
    if (
      existsSync(join(cwd, 'tests', 'unit.ts')) ||
      existsSync(join(cwd, 'tests', 'unit.js')) ||
      existsSync(join(cwd, 'tests', 'unit.tsx'))
    ) {
      execSync('npm run -s ws -- unit', { cwd, stdio });
    }
    // test grid
    if (example === 'spa-ts') {
      const server = spawn('npm', [ 'run', '-s', 'ws', '--', 'serve'], { cwd, stdio });
      execSync('npm run -s ws -- e2e --browsers ff', { cwd, stdio });
      // execSync('npm run -s ws -- e2e -g', { cwd, stdio });
      // execSync('npm run -s ws -- unit -g', { cwd, stdio });
      server.kill();
    }
  } catch (err) {
     throw `[ERROR] Couldn't update "${example}"!`;
  }
  console.log(`Finished updating "${example}".`);
});

console.log('Updated all examples ♥');
{'fraction_non_alphanumeric': 0.2107393416082029, 'fraction_numerical': 0.003507825148407987, 'mean_word_length': 3.0337323177366704, 'pattern_counts': {'":': 2, '<': 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': '90705', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1313, 'n_words': 313}