<commit_before>const _ = require('underscore');

const DEFAULTS = {
  before: 'export default ',
  after: ';\n'
};

module.exports = (file, options, cb) => {
  const source = file.buffer.toString();

  // Validate JSON.
  try { JSON.parse(source); } catch (er) { return cb(er); }

  options = _.extend({}, DEFAULTS, options);
  cb(null, {
    buffer: new Buffer(options.before + source.trim() + options.after)
  });
};<commit_msg>Wrap everything in a try<commit_after>const _ = require('underscore');

const DEFAULTS = {
  before: 'export default ',
  after: ';\n'
};

module.exports = (file, options, cb) => {
  try {
    const source = file.buffer.toString();

    // Validate JSON.
    JSON.parse(source);

    options = _.extend({}, DEFAULTS, options);
    cb(null, {
      buffer: new Buffer(options.before + source.trim() + options.after)
    });
  } catch (er) { return cb(er); }
};
{'fraction_non_alphanumeric': 0.17997750281214847, 'fraction_numerical': 0.0, 'mean_word_length': 3.3842364532019706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3881427', 'n_tokens_mistral': 295, 'n_tokens_neox': 294, 'n_words': 72}