<commit_before>const {readFileSync} = require('fs')
const {join} = require('path')

const replace = require('replace-in-file')
const chokidar = require('chokidar')

const postcss = require('postcss')
const autoprefixer = require('autoprefixer')
const cssnano = require('cssnano')

const postcssPlugins = [
  autoprefixer,
  cssnano()
]
// const postcssOptions = {}
// const filterType = /^text\/css$/

// Initialize watcher.
const watcher = chokidar.watch('./src/components/**/*.postcss', {
  persistent: true
})

// Something to use when events are received.
const log = console.log.bind(console)

const replaceHtml = (path, css) => {
  return replace({
    files: path,
    from: /<style>((.|\n)*)<\/style>/,
    to: `<style>
        ${css}
      </style>`
  }).then(changedFiles => changedFiles)
}

const compile = sourcePath => {
  const css = readFileSync(sourcePath, 'utf8')
  const splittedPath = sourcePath.split('/')
  const normalizedPath = splittedPath.splice(0, splittedPath.length - 1).join('/')
  const htmlPath = join(normalizedPath, 'style-module.html')

  postcss(postcssPlugins)
    .process(css)
    .then(cssRes => replaceHtml(htmlPath, cssRes))
		.then(compileFiles => log(`>> Compiled: ${sourcePath} -> ${compileFiles}`))
    .catch(err => console.error(`! ERR: ${err}`))
}
<commit_msg>Probably here we can return the original promise...<commit_after>const {readFileSync} = require('fs')
const {join} = require('path')

const replace = require('replace-in-file')
const chokidar = require('chokidar')

const postcss = require('postcss')
const autoprefixer = require('autoprefixer')
const cssnano = require('cssnano')

const postcssPlugins = [
  autoprefixer,
  cssnano()
]
// const postcssOptions = {}
// const filterType = /^text\/css$/

// Initialize watcher.
const watcher = chokidar.watch('./src/components/**/*.postcss', {
  persistent: true
})

// Something to use when events are received.
const log = console.log.bind(console)

const replaceHtml = (path, css) => {
  return replace({
    files: path,
    from: /<style>((.|\n)*)<\/style>/,
    to: `<style>
        ${css}
      </style>`
  })
}

const compile = sourcePath => {
  const css = readFileSync(sourcePath, 'utf8')
  const splittedPath = sourcePath.split('/')
  const normalizedPath = splittedPath.splice(0, splittedPath.length - 1).join('/')
  const htmlPath = join(normalizedPath, 'style-module.html')

  postcss(postcssPlugins)
    .process(css)
    .then(cssRes => replaceHtml(htmlPath, cssRes))
		.then(compileFiles => log(`>> Compiled: ${sourcePath} -> ${compileFiles}`))
    .catch(err => console.error(`! ERR: ${err}`))
}

{'fraction_non_alphanumeric': 0.17411225658648338, 'fraction_numerical': 0.002290950744558992, 'mean_word_length': 4.137254901960785, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 28, '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': '3684369', 'n_tokens_mistral': 876, 'n_tokens_neox': 876, 'n_words': 197}