<commit_before>var fs   = require('fs');
var path = require('path');
var Q    = require('kew');

var gonzales = require('gonzales-pe');

module.exports = function(file){
  return {
    name:   path.basename(file.path).split('.')[0],
    cssDOM: gonzales.parse(file.contents.toString('utf8'), { syntax: 'scss' })
  };
};<commit_msg>Set gonzales-pe syntax based on the file extension. Throw an error if trying to process a file not of type css, scss, sass, or less.<commit_after>var fs   = require('fs');
var path = require('path');
var Q    = require('kew');
var _    = require('lodash');

var gutil       = require('gulp-util');
var PluginError = gutil.PluginError;

var gonzales = require('gonzales-pe');

var PLUGIN_NAME = 'gulp-polish';

module.exports = function(file, syntax){
  var filetype = path.extname(file.path).replace('.','').toLowerCase();

  if (!_.contains(['css','scss','sass','less'], filetype)){
    throw new PluginError(PLUGIN_NAME, 'Only files with the following extensions can be polished: css, scss, sass, less.');
  }

  return {
    name:   path.basename(file.path).split('.')[0],
    cssDOM: gonzales.parse(file.contents.toString('utf8'), { syntax: filetype })
  };
};
{'fraction_non_alphanumeric': 0.17824267782426778, 'fraction_numerical': 0.0033472803347280333, 'mean_word_length': 4.387387387387387, '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': '4717162', 'n_tokens_mistral': 407, 'n_tokens_neox': 399, 'n_words': 100}