<commit_before>#!/usr/bin/env node
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var execa = require('execa')
var ms = require('ms')
var dateFormat = require('dateformat')
var pageresPath = '"' + path.join(__dirname, './node_modules/.bin/pageres') + '"'

var yargs = require('yargs')
  .usage('Usage: $0 [options] -- <pageres-cli-options>')
  .option('every', {
    alias: 'e',
    describe: 'screenshots interval',
    default: '1m',
    type: 'string'
  })
  .option('directory', {
    alias: 'd',
    describe: 'screenshots directory',
    default: './tlapse',
    type: 'string'
  })
  .help()
  .version()

var argv = yargs.argv

if (argv._.length === 0) {
  yargs.showHelp()
  process.exit(1)
}

if (argv.directory) {
  mkdirp.sync(argv.directory)
  process.chdir(argv.directory)
}

console.log('Screenshots directory:', argv.directory)
console.log('Interval:', argv.every)

function run () {
  var pageresOptions = argv._.join(' ')
  var cmd = [
    pageresPath,
    pageresOptions,
    '--filename=' + Date.now()
  ].join(' ')

  const result = execa.shellSync(cmd, {
    cwd: path.join(__dirname, './node_modules/.bin')
  })

  if (result.status !== 0) {
    console.log('Error')
    console.log('stdout:', result.stdout)
    console.log('stderr:', result.stderr)
  } else {
    var recentFiles = fs
      .readdirSync(process.cwd())
      .reverse()

    var latestFile = recentFiles[0]<commit_msg>Save screenshots in the proper directory<commit_after>#!/usr/bin/env node
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var execa = require('execa')
var ms = require('ms')
var dateFormat = require('dateformat')
var pageresPath = '"' + path.join(__dirname, './node_modules/.bin/pageres') + '"'

var yargs = require('yargs')
  .usage('Usage: $0 [options] -- <pageres-cli-options>')
  .option('every', {
    alias: 'e',
    describe: 'screenshots interval',
    default: '1m',
    type: 'string'
  })
  .option('directory', {
    alias: 'd',
    describe: 'screenshots directory',
    default: './tlapse',
    type: 'string'
  })
  .help()
  .version()

var argv = yargs.argv

if (argv._.length === 0) {
  yargs.showHelp()
  process.exit(1)
}

if (argv.directory) {
  mkdirp.sync(argv.directory)
  process.chdir(argv.directory)
}

console.log('Screenshots directory:', argv.directory)
console.log('Interval:', argv.every)

function run () {
  var pageresOptions = argv._.join(' ')
  var cmd = [
    pageresPath,
    pageresOptions,
    '--filename=' + Date.now()
  ].join(' ')

  const result = execa.shellSync(cmd)

  if (result.status !== 0) {
    console.log('Error')
    console.log('stdout:', result.stdout)
    console.log('stderr:', result.stderr)
  } else {
    var recentFiles = fs
      .readdirSync(process.cwd())
      .reverse()

    var latestFile = recentFiles[0]
{'fraction_non_alphanumeric': 0.1829652996845426, 'fraction_numerical': 0.004206098843322818, 'mean_word_length': 3.4733542319749215, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1281177', 'n_tokens_mistral': 1025, 'n_tokens_neox': 987, 'n_words': 211}