<commit_before>_ = require('lodash')
coffeeify = require('coffeeify')
fs = require('fs')
harp = require('harp')
stylus = require('stylus')
watchify = require('watchify')


bundle = (w) ->
  return w.bundle({ standalone: 'Quill' })

serve = (connect, req, res, next) ->
  watchers = connect.watchers
  switch req.url
    when '/quill.js'
      res.setHeader('Content-Type', 'application/javascript')
      bundle(watchers['src']).pipe(res)
    when '/test/quill.js'
      res.setHeader('Content-Type', 'application/javascript')
      bundle(watchers['test']).pipe(res)
    when '/quill.snow.css'
      res.setHeader('Content-Type', 'text/css')
      fs.readFile('./src/themes/snow/snow.styl', (err, data) ->
        s = stylus(data.toString())
        s.include('./src/themes/snow')
        s.define('url', stylus.url())
        s.render((err, css) ->
          res.write(css)
          res.end()
        )
      )
    else
      next()


module.exports = (grunt) ->
  grunt.config('connect',
    options:
      onCreateServer: (server, connect, options) ->
        connect.watchers = _.reduce(['src', 'test'], (watchers, type) ->
          file = if type == 'src' then './src/index.coffee' else './test/quill.coffee'
          w = watchify(file, { extensions: ['.js', '.coffee'] })
          watchers[type] = w
          w.require('./.build/lodash.js', { expose: 'lodash' })
          w.transform(coffeeify)
          w.on('update', bundle.bind(this, w))
          bundle(w) if options.keepalive
          return watchers
        , {})
      middleware: (connect, options, middlewares) ->
        middlewares.push(serve.bind(this, connect))
        middlewares.push(harp.mount(__dirname + '/../..'))
        return middlewares
      debug: true
    server:
      options:
        port: grunt.config('port')
        useAvailablePort: true
  )

  grunt.event.once('connect.server.listening', (host, port) ->
    grunt.config.set('port', port)
  )
<commit_msg>Some proxies insist on a favicon<commit_after>_ = require('lodash')
coffeeify = require('coffeeify')
fs = require('fs')
harp = require('harp')
stylus = require('stylus')
watchify = require('watchify')


FAVICON = new Buffer('<KEY>', 'base64')


bundle = (w) ->
  return w.bundle({ standalone: 'Quill' })

serve = (connect, req, res, next) ->
  watchers = connect.watchers
  switch req.url
    when '/quill.js'
      res.setHeader('Content-Type', 'application/javascript')
      bundle(watchers['src']).pipe(res)
    when '/test/quill.js'
      res.setHeader('Content-Type', 'application/javascript')
      bundle(watchers['test']).pipe(res)
    when '/quill.snow.css'
      res.setHeader('Content-Type', 'text/css')
      fs.readFile('./src/themes/snow/snow.styl', (err, data) ->
        s = stylus(data.toString())
        s.include('./src/themes/snow')
        s.define('url', stylus.url())
        s.render((err, css) ->
          res.end(css)
        )
      )
    when '/favicon.ico'
      res.setHeader('Content-Type', 'image/png')
      res.end(FAVICON)
    else
      next()


module.exports = (grunt) ->
  grunt.config('connect',
    options:
      onCreateServer: (server, connect, options) ->
        connect.watchers = _.reduce(['src', 'test'], (watchers, type) ->
          file = if type == 'src' then './src/index.coffee' else './test/quill.coffee'
          w = watchify(file, { extensions: ['.js', '.coffee'] })
          watchers[type] = w
          w.require('./.build/lodash.js', { expose: 'lodash' })
          w.transform(coffeeify)
          w.on('update', bundle.bind(this, w))
          bundle(w) if options.keepalive
          return watchers
        , {})
      middleware: (connect, options, middlewares) ->
        middlewares.push(serve.bind(this, connect))
        middlewares.push(harp.mount(__dirname + '/../..'))
        return middlewares
      debug: true
    server:
      options:
        port: grunt.config('port')
        useAvailablePort: true
  )

  grunt.event.once('connect.server.listening', (host, port) ->
    grunt.config.set('port', port)
  )

{'fraction_non_alphanumeric': 0.17633983699678932, 'fraction_numerical': 0.0004939491232403062, 'mean_word_length': 2.5217391304347827, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 22, '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': '783677', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1334, 'n_words': 247}