<commit_before>// Basic parser for less sources
module.exports = function(ctx, done) {
  if(!/\.less$/i.test(ctx.filename)) return done();

  // Let user manage stylus version
  try {
    less = require('less')
  } catch(e) {
    throw new Error('You must install less package to use less sources')
  }

  var parser = new(less.Parser)({
    filename: ctx.filename
  })

  parser.parse(ctx.src, function (err, tree) {
    if(err) return done(err);
    ctx.src = tree.toCSS({
      sourceMap: true,
      writeSourceMap: function(map) { ctx.map = map }
    })
    done(null, ctx)
  })
}<commit_msg>fix: Less breaking changes<commit_after>var semver  = require('semver')

// Basic parser for less sources
module.exports = function(ctx, done) {
  if(!/\.less$/i.test(ctx.filename)) return done();

  var less, pkg;
  // Let user manage stylus version
  try {
    less = require('less')
    pkg  = require('less/package.json')
  } catch(e) {
    throw new Error('You must install less package to use less sources')
  }

  if(semver.lt(pkg.version,'2.0.0')) {
    var parser = new(less.Parser)({
      filename: ctx.filename
    })

    parser.parse(ctx.src, function (err, tree) {
      if(err) return done(err);
      ctx.src = tree.toCSS({
        sourceMap: true,
        writeSourceMap: function(map) { ctx.map = map }
      })
      done(null, ctx)
    })

  // Starting from v2.0.0
  } else {
    var options = {
      filename  : ctx.filename,
      sourceMap : true
    }
    less.render(ctx.src, options, function(err, result) {
      if(err) return done(err);
      ctx.src = result.css
      ctx.map = result.map
      done(null, ctx)
    })
  }

}
{'fraction_non_alphanumeric': 0.14622356495468278, 'fraction_numerical': 0.0036253776435045317, 'mean_word_length': 2.576673866090713, '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': '1159378', 'n_tokens_mistral': 561, 'n_tokens_neox': 546, 'n_words': 142}