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

const fs = require('fs');
const path = require('path');
const commander = require('commander');
const mkdirp = require('mkdirp');
const ncp = require('ncp').ncp;


commander
  .option('-p, --pattern <regexp>', 'Regexp used to parse the lists on stdin (ex: "^lib\/([^\/]+).*\/([^\/]+)$"')
  .option('-d, --dest <string>', 'String that owns pattern matches (ex: /path/to/img/$1/$2')
  .parse(process.argv);

/* Main */

if (process.argv.length < 3) {
  process.stdout.write('Missing arguments.');
  commander.help();
  process.exit(1);
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

const timeID = setTimeout(() => {
  process.stdout.write('No data received from stdin!');
  commander.help();
  process.exit(1);
}, 2000);

var dataStdin = '';
process.stdin.on('data', (data) => {
  clearTimeout(timeID);
  dataStdin += data;
});

process.stdin.on('end', () => {
  if (dataStdin === '') {
    process.exit(0);
  }

  const list = dataStdin.split(/\s+/).filter(Boolean);

  list.forEach(file => {
    const regexp = new RegExp(commander.pattern);
    const src = path.resolve(path.join(process.cwd(), file));
    const dest = path.resolve(file.replace(regexp, commander.dest));

    // create dest dir
    mkdirp.sync(path.dirname(dest));

    if (src !== dest) {
      const stats = fs.statSync(src);
<commit_msg>Add a timeout argument and increase default value<commit_after>#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const commander = require('commander');
const mkdirp = require('mkdirp');
const ncp = require('ncp').ncp;


commander
  .option('-p, --pattern <regexp>', 'Regexp used to parse the lists on stdin (ex: "^lib\/([^\/]+).*\/([^\/]+)$"')
  .option('-d, --dest <string>', 'String that owns pattern matches (ex: /path/to/img/$1/$2')
  .option('-t, --timeout <number>', 'Timeout to wait for data until the process exits', 5000)
  .parse(process.argv);

/* Main */

if (process.argv.length < 3) {
  process.stdout.write('Missing arguments.');
  commander.help();
  process.exit(1);
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

const timeID = setTimeout(() => {
  process.stdout.write('No data received from stdin!');
  commander.help();
  process.exit(1);
}, commander.timeout);

var dataStdin = '';
process.stdin.on('data', (data) => {
  clearTimeout(timeID);
  dataStdin += data;
});

process.stdin.on('end', () => {
  if (dataStdin === '') {
    process.exit(0);
  }

  const list = dataStdin.split(/\s+/).filter(Boolean);

  list.forEach(file => {
    const regexp = new RegExp(commander.pattern);
    const src = path.resolve(path.join(process.cwd(), file));
    const dest = path.resolve(file.replace(regexp, commander.dest));

    // create dest dir
    mkdirp.sync(path.dirname(dest));

    if (src !== dest) {
      const stats = fs.statSync(src);

{'fraction_non_alphanumeric': 0.2057900244157656, 'fraction_numerical': 0.0076735263341471925, 'mean_word_length': 3.8445945945945947, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 16, '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': '7257698', 'n_tokens_mistral': 1001, 'n_tokens_neox': 986, 'n_words': 220}