<commit_before>/* fs.js
 * Wrappers for filesystem functions for logging.
 */

var fs = require('fs');
var winston = require('winston');

exports.unlink = function(path, canFail) {
  fs.unlink(path, function(err) {
    if (err && !canFail)
      winston.error('Failed to delete "' + path + '": ' + err.message);
    else if (!err)
      winston.info('Deleted file: ' + path);
  });
};
<commit_msg>My fs.unlink returns a promise.<commit_after>/* fs.js
 * Wrappers for filesystem functions for logging.
 */

var fs = require('fs');
var winston = require('winston');
var Q = require('q');

exports.unlink = function(path, canFail) {
  var deferred = Q.defer();

  fs.unlink(path, function(err) {
    if (err && !canFail) {
      winston.error('Failed to delete "' + path + '": ' + err.message);
      deferred.reject(err);
    } else if (!err) {
      winston.info('Deleted file: ' + path);
      deferred.resolve();
    } else {
      deferred.resolve();
    }
  });

  return deferred.promise;
};

{'fraction_non_alphanumeric': 0.17369477911646586, 'fraction_numerical': 0.0, 'mean_word_length': 3.154166666666667, 'pattern_counts': {'":': 2, '<': 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': '1587854', 'n_tokens_mistral': 337, 'n_tokens_neox': 332, 'n_words': 82}