<commit_before>path = require 'path'
os = require 'os'
LessCache = require 'less-cache'
{Subscriber} = require 'emissary'

tmpDir = if process.platform is 'win32' then os.tmpdir() else '/tmp'

module.exports =
class LessCompileCache
  Subscriber.includeInto(this)

  @cacheDir: path.join(tmpDir, 'atom-compile-cache', 'less')

  constructor: ({resourcePath})->
    @cache = new LessCache
      cacheDir: @constructor.cacheDir
      importPaths: @getImportPaths()
      resourcePath: window.resourcePath
      fallbackDir: path.join(resourcePath, 'less-compile-cache')

    @lessSearchPaths = [
      path.join(resourcePath, 'static', 'variables')
      path.join(resourcePath, 'static')
    ]

    @subscribe atom.themes, 'reloaded', => @cache.setImportPaths(@getImportPaths())

  getImportPaths: -> atom.themes.getImportPaths().concat(@lessSearchPaths)

  read: (stylesheetPath) -> @cache.readFileSync(stylesheetPath)

  destroy: -> @unsubscribe()<commit_msg>Set paths before creating cache<commit_after>path = require 'path'
os = require 'os'
LessCache = require 'less-cache'
{Subscriber} = require 'emissary'

tmpDir = if process.platform is 'win32' then os.tmpdir() else '/tmp'

module.exports =
class LessCompileCache
  Subscriber.includeInto(this)

  @cacheDir: path.join(tmpDir, 'atom-compile-cache', 'less')

  constructor: ({resourcePath}) ->
    @lessSearchPaths = [
      path.join(resourcePath, 'static', 'variables')
      path.join(resourcePath, 'static')
    ]

    @cache = new LessCache
      cacheDir: @constructor.cacheDir
      importPaths: @getImportPaths()
      resourcePath: window.resourcePath
      fallbackDir: path.join(resourcePath, 'less-compile-cache')

    @subscribe atom.themes, 'reloaded', => @cache.setImportPaths(@getImportPaths())

  getImportPaths: -> atom.themes.getImportPaths().concat(@lessSearchPaths)

  read: (stylesheetPath) -> @cache.readFileSync(stylesheetPath)

  destroy: -> @unsubscribe()
{'fraction_non_alphanumeric': 0.1371841155234657, 'fraction_numerical': 0.0020629190304280558, 'mean_word_length': 4.542857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6514105', 'n_tokens_mistral': 603, 'n_tokens_neox': 580, 'n_words': 123}