<commit_before>'use strict'
const chokidar = require('chokidar')
const path = require('path')
const socketsConnected = []
let baseURL
try {
  const pjson = require(path.join(path.dirname(require.main.filename), 'package.json'))
  baseURL = pjson.jspm.directories.baseURL || pjson.directories.baseURL
} catch (err) {}
if (baseURL) {
  console.log('using baseURL from package.json: ', baseURL)
}

module.exports = (opts, cb) => {
  let app = opts.app
  if (!app) {
    app = require('http').createServer()
  }

  var io = require('socket.io')(app)
  if (!opts.app) {
    let port = opts.port || 9111
    app.listen(port, () => {
      console.log('chokidar listening on ', port)
      cb && cb()
    })
  }
  let pathToWath = opts.path || baseURL || '.'
  let chokidarOpts = Object.assign({
    ignored: /[\/\\]\./,
    ignoreInitial: true
  }, opts.chokidar)
  var watcher = chokidar.watch(pathToWath, chokidarOpts).on('all', (event, onPath) => {
    let absolutePath = path.join(process.cwd(), onPath)
    if (opts.relativeTo) {
      onPath = path.relative(opts.relativeTo, onPath)
    } else if (baseURL) {
      onPath = path.relative(baseURL, onPath)
    }
    if (path.sep === '\\') {
      onPath = onPath.replace(/\\/g, '/')
    } else {

    }
    console.log('File ', onPath, ' emitted: ', event)
    socketsConnected.forEach((socket) => {
      socket.emit(event, {path: onPath, absolutePath})
    })
  })
  io.on('connection', (socket) => {
    let index = socketsConnected.push(socket)
    socket.on('disconnect', () => {
      socketsConnected.splice(index - 1, 1)
    })

    socket.on('identification', (name) => {
      console.log('connected client: ', name)
    })
  })

  return {
    io: io,
    app: app,
    watcher: watcher,
    close: (callback) => {
      watcher.close()
      console.log('closing chokidar-socket-emitter')
      socketsConnected.forEach((socket) => {
        socket.disconnect()
      })
      io.httpServer.close(callback)
    }
  }
}
<commit_msg>added node_modules and jspm_packages to ignored by default<commit_after>'use strict'
const chokidar = require('chokidar')
const path = require('path')
const socketsConnected = []
let baseURL
try {
  const pjson = require(path.join(path.dirname(require.main.filename), 'package.json'))
  baseURL = pjson.jspm.directories.baseURL || pjson.directories.baseURL
} catch (err) {}
if (baseURL) {
  console.log('using baseURL from package.json: ', baseURL)
}

module.exports = (opts, cb) => {
  let app = opts.app
  if (!app) {
    app = require('http').createServer()
  }

  var io = require('socket.io')(app)
  if (!opts.app) {
    let port = opts.port || 9111
    app.listen(port, () => {
      console.log('chokidar listening on ', port)
      cb && cb()
    })
  }
  let pathToWath = opts.path || baseURL || '.'
  let chokidarOpts = Object.assign({
    ignored: [/[\/\\]\./, 'node_modules/**', 'jspm_packages/**'],
    ignoreInitial: true
  }, opts.chokidar)
  var watcher = chokidar.watch(pathToWath, chokidarOpts).on('all', (event, onPath) => {
    let absolutePath = path.join(process.cwd(), onPath)
    if (opts.relativeTo) {
      onPath = path.relative(opts.relativeTo, onPath)
    } else if (baseURL) {
      onPath = path.relative(baseURL, onPath)
    }
    if (path.sep === '\\') {
      onPath = onPath.replace(/\\/g, '/')
    } else {

    }
    console.log('File ', onPath, ' emitted: ', event)
    socketsConnected.forEach((socket) => {
      socket.emit(event, {path: onPath, absolutePath})
    })
  })
  io.on('connection', (socket) => {
    let index = socketsConnected.push(socket)
    socket.on('disconnect', () => {
      socketsConnected.splice(index - 1, 1)
    })

    socket.on('identification', (name) => {
      console.log('connected client: ', name)
    })
  })

  return {
    io: io,
    app: app,
    watcher: watcher,
    close: (callback) => {
      watcher.close()
      console.log('closing chokidar-socket-emitter')
      socketsConnected.forEach((socket) => {
        socket.disconnect()
      })
      io.httpServer.close(callback)
    }
  }
}

{'fraction_non_alphanumeric': 0.17248157248157248, 'fraction_numerical': 0.0029484029484029483, 'mean_word_length': 2.921965317919075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '2420630', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1413, 'n_words': 269}