<commit_before>var path = require('path')
var fs = require('fs')
var http = require('http')
var tinylr = require('tiny-lr')
var chokidar = require('chokidar')
var st = require('st')

var defaults = {
  passthrough: false,
  index: 'index.html',
  port: 3000,
  lrPort: 35729,
  dir: path.resolve(process.cwd(), 'public')
}

module.exports = function (options) {
  var debug = require('debug')
  var opts = {}
  
  Object.keys(defaults).forEach(function (key) {
    if (!(key in options)) {
      opts[key] = defaults[key]
    } else {
      opts[key] = options[key]
    }
  })

  opts.dir = path.resolve(process.cwd(), opts.dir)

  var log = debug('drudge')
  var logChange = debug('drudge:change')
  var logReq = debug('drudge:req')

  var watcher = chokidar.watch(opts.dir, { ignoreInitial: true, persistent: true })

  log('Watching %s', opts.dir)
  watcher
    .on('error', function (error) {
      log('Error', error)
    })
    .on('change', triggerReload)
    .on('add', triggerReload)

  function triggerReload (filepath) {
    var fileName = path.basename(filepath)
    logChange(fileName)
    tinylr.changed(fileName)
  }

  var lrServer = tinylr()
  lrServer.listen(opts.lrPort, function() {
    log('LiveReload listening on http://localhost:%s', opts.lrPort)
  })

  var mount = st({
    path: opts.dir,
    url: '/',
    passthrough: opts.passthrough,
    index: opts.index,
    cache: false
  })

  var httpServer = http.createServer(function (req, res) {
    logReq('%s - %s', req.method, req.url)
    mount(req, res, function() {
      res.setHeader('content-type', 'text/html')
      fs.createReadStream(path.join(opts.dir, 'index.html')).pipe(res)
    })
  }).listen(opts.port, function () {
    log('HTTP Server listening on http://localhost:%s', opts.port)
  })

  return {
    watcher: watcher,
    lrServer: lrServer,
    httpServer: httpServer
  }
}<commit_msg>ignore dotfiles<commit_after>var path = require('path')
var fs = require('fs')
var http = require('http')
var tinylr = require('tiny-lr')
var chokidar = require('chokidar')
var st = require('st')

var defaults = {
  passthrough: false,
  index: 'index.html',
  port: 3000,
  lrPort: 35729,
  dir: path.resolve(process.cwd(), 'public')
}

module.exports = function (options) {
  var debug = require('debug')
  var opts = {}
  
  Object.keys(defaults).forEach(function (key) {
    if (!(key in options)) {
      opts[key] = defaults[key]
    } else {
      opts[key] = options[key]
    }
  })

  opts.dir = path.resolve(process.cwd(), opts.dir)

  var log = debug('drudge')
  var logChange = debug('drudge:change')
  var logReq = debug('drudge:req')

  var watcher = chokidar.watch(opts.dir, {
    ignoreInitial: true,
    ignored: /[\/\\]\./,
    persistent: true
  })

  log('Watching %s', opts.dir)
  watcher
    .on('error', function (error) {
      log('Error', error)
    })
    .on('change', triggerReload)
    .on('add', triggerReload)

  function triggerReload (filepath) {
    var fileName = path.basename(filepath)
    logChange(fileName)
    tinylr.changed(fileName)
  }

  var lrServer = tinylr()
  lrServer.listen(opts.lrPort, function() {
    log('LiveReload listening on http://localhost:%s', opts.lrPort)
  })

  var mount = st({
    path: opts.dir,
    url: '/',
    passthrough: opts.passthrough,
    index: opts.index,
    cache: false
  })

  var httpServer = http.createServer(function (req, res) {
    logReq('%s - %s', req.method, req.url)
    mount(req, res, function() {
      res.setHeader('content-type', 'text/html')
      fs.createReadStream(path.join(opts.dir, 'index.html')).pipe(res)
    })
  }).listen(opts.port, function () {
    log('HTTP Server listening on http://localhost:%s', opts.port)
  })

  return {
    watcher: watcher,
    lrServer: lrServer,
    httpServer: httpServer
  }
}
{'fraction_non_alphanumeric': 0.1650459921156373, 'fraction_numerical': 0.004730617608409987, 'mean_word_length': 3.295711060948081, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2286023', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1332, 'n_words': 288}