<commit_before>
// allow to require('riot')
const
  path = require('path'),
  fs = require('fs'),
  riotPath = process.env.RIOT || path.resolve(__dirname, '../../riot'),
  riot = require(riotPath),
  // simple-dom helper
  sdom = require('./sdom'),
  compiler = require('riot-compiler'),
  cache = {}

// shared function that will be used by riot.load and by require('some.tag')
function loadAndCompile(filename, opts) {
  var src = compiler.compile(fs.readFileSync(filename, 'utf8'), opts)
  global.riot = riot
  module._compile(`module.exports = ${ src }`, filename)
  delete global.riot
}

// enable the loading of riot tags with options riot.require('some.tag', { template: 'pug' })
function riotRequire(filename, opts) {
  if (cache[filename]) {
    return cache[filename]
  }<commit_msg>updated: check if riot was already global available<commit_after>
// allow to require('riot')
const
  path = require('path'),
  fs = require('fs'),
  riotPath = process.env.RIOT || path.resolve(__dirname, '../../riot'),
  riot = require(riotPath),
  // simple-dom helper
  sdom = require('./sdom'),
  compiler = require('riot-compiler'),
  cache = {}

// shared function that will be used by riot.load and by require('some.tag')
function loadAndCompile(filename, opts) {
  var src = compiler.compile(fs.readFileSync(filename, 'utf8'), opts)
  var hasGlobalRiot = typeof global.riot !== 'undefined'
  if (!hasGlobalRiot) global.riot = riot
  module._compile(`module.exports = ${ src }`, filename)
  if (!hasGlobalRiot) delete global.riot
}

// enable the loading of riot tags with options riot.require('some.tag', { template: 'pug' })
function riotRequire(filename, opts) {
  if (cache[filename]) {
    return cache[filename]
  }
{'fraction_non_alphanumeric': 0.1568855316676351, 'fraction_numerical': 0.0011621150493898896, 'mean_word_length': 4.186746987951807, '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': '3470753', 'n_tokens_mistral': 545, 'n_tokens_neox': 515, 'n_words': 148}