<commit_before>#!/usr/bin/env node

'use strict';

const chalk = require('chalk');
const globby = require('globby');
const path = require('path');
const utils = require('./utils.js');
const host = 'node' + process.version[1];
let target = process.argv[2] || 'host';
if (target === 'host') target = host;
const modify = process.argv[3] || 'all';

console.log('');
console.log('*************************************');
console.log(host + ' ' + modify);
console.log('*************************************');
console.log('');

const list = [];

if (modify === 'only-npm') {
  list.push(path.join(__dirname, 'test-79-npm/main.js'));
} else {
  list.push(path.join(__dirname, '*/main.js'));
  if (modify === 'no-npm') {
    list.push('!' + path.join(__dirname, 'test-42-fetch-all/**/*'));
    list.push('!' + path.join(__dirname, 'test-79-npm/**/*'));
  }
}

const files = globby.sync(list);

files.sort().some(function (file) {
  file = path.resolve(file);
  try {
    utils.spawn.sync(
      'node', [ path.basename(file), target ],
      { cwd: path.dirname(file), stdio: 'inherit' }
    );
  } catch (error) {
    console.log();
    console.log(`> ${chalk.red('Error!')} ${error.message}`);
    console.log(`> ${chalk.red('Error!')} ${file} FAILED (in ${target})`);
    process.exit(2);
  }
  console.log(file, 'ok');<commit_msg>test/test.js improvement for manual run (one more)<commit_after>#!/usr/bin/env node

'use strict';

const chalk = require('chalk');
const globby = require('globby');
const path = require('path');
const utils = require('./utils.js');
const host = 'node' + process.version[1];
let target = process.argv[2] || 'host';
if (target === 'host') target = host;
const modify = process.argv[3] || 'all';

console.log('');
console.log('*************************************');
console.log(target + ' ' + modify);
console.log('*************************************');
console.log('');

const list = [];

if (modify === 'only-npm') {
  list.push(path.join(__dirname, 'test-79-npm/main.js'));
} else {
  list.push(path.join(__dirname, '*/main.js'));
  if (modify === 'no-npm') {
    list.push('!' + path.join(__dirname, 'test-42-fetch-all/**/*'));
    list.push('!' + path.join(__dirname, 'test-79-npm/**/*'));
  }
}

const files = globby.sync(list);

files.sort().some(function (file) {
  file = path.resolve(file);
  try {
    utils.spawn.sync(
      'node', [ path.basename(file), target ],
      { cwd: path.dirname(file), stdio: 'inherit' }
    );
  } catch (error) {
    console.log();
    console.log(`> ${chalk.red('Error!')} ${error.message}`);
    console.log(`> ${chalk.red('Error!')} ${file} FAILED (in ${target})`);
    process.exit(2);
  }
  console.log(file, 'ok');
{'fraction_non_alphanumeric': 0.28592647604901594, 'fraction_numerical': 0.007426661715558856, 'mean_word_length': 4.251461988304094, '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': '3654387', 'n_tokens_mistral': 953, 'n_tokens_neox': 927, 'n_words': 183}