<commit_before>import {watch} from 'chokidar';

import devServer from './devServer.js';
import builder from './builder.js';
import {start as middlewares} from './middlewares';
import {rootPath} from './path.js';

// we build once at start
builder({middlewares}, err => {
  if (err) {
    throw err;
  }

  // watch and serve docs/ (browser sync)
  devServer();
});

// then we watch and rebuild
watch([
  rootPath('docgen/assets/'),
  rootPath('docgen/src/**/*'),
  rootPath('docgen/layouts/**/*.pug'),
  rootPath('src/**/*.js'),
], {
  ignoreInitial: true,
  ignored: /assets\/js\/(.*)?\.js$/,
})
  .on('all', (event, filePath) => {
    // filter out plugins we dont need on some files changes
    // example: remove `documentationjs` when no src/ files changed.
    const isSrcFileChange = event === 'change'
      && filePath.includes('src/')
      && !filePath.includes('docgen')

    const nextMiddlewares = isSrcFileChange
      ? middlewares
      : middlewares.filter(fn => fn.name !== 'documentationjs')

    builder({clean: false, middlewares: nextMiddlewares}, err => {
      if (err) {
        throw err;
      }
    })
  })
  .on('error', err => {
    throw err;
  });<commit_msg>chore(doc.build): dont re-build sass when not needed<commit_after>import {watch} from 'chokidar';

import devServer from './devServer.js';
import builder from './builder.js';
import {start as middlewares} from './middlewares';
import {rootPath} from './path.js';

// we build once at start
builder({middlewares}, err => {
  if (err) {
    throw err;
  }

  // watch and serve docs/ (browser sync)
  devServer();
});

// then we watch and rebuild
watch([
  rootPath('docgen/assets/'),
  rootPath('docgen/src/**/*'),
  rootPath('docgen/layouts/**/*.pug'),
  rootPath('src/**/*.js'),
], {
  ignoreInitial: true,
  ignored: /assets\/js\/(.*)?\.js$/,
})
  .on('all', (event, filePath) => {
    // filter out plugins we dont need on some files changes
    // example: remove `documentationjs` when no src/ files changed.
    const isSrcFileChange = event === 'change'
      && filePath.includes('src/')
      && !filePath.includes('docgen')

    const isSassFile =  event === 'change'
      && filePath.includes('docgen')
      && /^[^_.].*\.s[ac]ss/.test(filePath)

    const nextMiddlewares = middlewares
      .filter(fn =>
        !isSrcFileChange && fn.name !== 'documentationjs'
      )
      .filter(fn =>
        !isSassFile && (fn.name === 'bound compileSass' || fn.name === 'sassAutoprefixer')
          ? false
          : true
      )

    builder({clean: false, middlewares: nextMiddlewares}, err => {
      if (err) {
        throw err;
      }
    })
  })
  .on('error', err => {
    throw err;
  });
{'fraction_non_alphanumeric': 0.18245743893412286, 'fraction_numerical': 0.0, 'mean_word_length': 2.844950213371266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '178664', 'n_tokens_mistral': 906, 'n_tokens_neox': 886, 'n_words': 223}