<commit_before>'use strict'

const fs = require('fs-extra')
const path = require('path')
const httpServer = require('http-server')
const chokidar = require('chokidar')
const DistBuilder = require('../lib/DistBuilder')

// watch all the .njk files in templates/ and styles in templates/scss/
const watcher = chokidar.watch(['./templates/*.njk', './templates/scss/*/**.scss'])

// build all the templates to `./dist/`
watcher.on('ready', () => buildTemplates())

watcher.on('change', path => {
  console.info(`File ${path} changed...`)

  if (!path.includes('.njk')) {
    buildTemplates()
    return
  }

  // rebuild all templates if change is made to the master template
  if (path.includes('master.njk')) {
    buildTemplates()
    return
  }

  buildTemplate(path)
})

// start the http server
const server = httpServer.createServer({ root: './dist/' })
server.listen(8080)
console.info('File server working on http://localhost:8080')

/**
 * Builds all templates
 */
const buildTemplates = () => {
  console.info('Building all templates to `./dist/`')

  // remove `./dist/` before building the templates
  clearBuilds()<commit_msg>Disable cache on dev http server<commit_after>'use strict'

const fs = require('fs-extra')
const path = require('path')
const httpServer = require('http-server')
const chokidar = require('chokidar')
const DistBuilder = require('../lib/DistBuilder')

// watch all the .njk files in templates/ and styles in templates/scss/
const watcher = chokidar.watch(['./templates/*.njk', './templates/scss/*/**.scss'])

// build all the templates to `./dist/`
watcher.on('ready', () => buildTemplates())

watcher.on('change', path => {
  console.info(`File ${path} changed...`)

  if (!path.includes('.njk')) {
    buildTemplates()
    return
  }

  // rebuild all templates if change is made to the master template
  if (path.includes('master.njk')) {
    buildTemplates()
    return
  }

  buildTemplate(path)
})

// start the http server
const server = httpServer.createServer({ root: './dist/', cache: -1 })
server.listen(8080)
console.info('File server working on http://localhost:8080')

/**
 * Builds all templates
 */
const buildTemplates = () => {
  console.info('Building all templates to `./dist/`')

  // remove `./dist/` before building the templates
  clearBuilds()
{'fraction_non_alphanumeric': 0.16898349261511728, 'fraction_numerical': 0.007384882710686359, 'mean_word_length': 3.8280922431865827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '622523', 'n_tokens_mistral': 723, 'n_tokens_neox': 698, 'n_words': 200}