<commit_before>'use strict';

var fs        = require('fs')
  , envReader = require('env-reader')()
  , envParser = require('env-parser')()
  , envWriter = require('env-writer')()
  , envData

module.exports = function (envFile, callback) {
  if (typeof envFile === 'function') {
    callback = envFile;
    envFile = undefined;
  }

  if (!callback) {
    callback = function() { /* noop */ }
  }

  if (typeof envFile === 'undefined')
    envFile = '.env';

  try {
    envData = fs.readFileSync(envFile);
  } catch(e) {
    callback(e);
    return false;
  }

  envReader.pipe(envParser).pipe(envWriter);
  envReader.write(envData);

  envReader.on('end', callback);
  envReader.removeAllListeners();
  envWriter.removeAllListeners();
  envParser.removeAllListeners();
}
<commit_msg>support blocking/unblocking process type<commit_after>'use strict';

var fs        = require('fs')
  , envReader = require('env-reader')()
  , envParser = require('env-parser')()
  , envWriter = require('env-writer')()
  , envData

module.exports = function (envFile, callback) {
  if (typeof envFile === 'function') {
    callback = envFile;
    envFile = undefined;
  }

  if (typeof envFile === 'undefined')
    envFile = '.env';

  if (!callback) {
    try {
      envData = fs.readFileSync(envFile);
    } catch(e) {
      return false;
    }

    envReader.pipe(envParser).pipe(envWriter);
    envReader.write(envData);
  } else {
    // supress warning on test
    envReader.removeAllListeners();
    envParser.removeAllListeners();

    fs.createReadStream(envFile)
      .on('error', function(e) {
        return callback.call(null, e);
      })
      .on('end', function() {
        return callback.call(null);
      })
      .pipe(envReader)
      .pipe(envParser)
      .pipe(envWriter);
  }
}

{'fraction_non_alphanumeric': 0.15848214285714285, 'fraction_numerical': 0.0, 'mean_word_length': 3.0657596371882088, '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': '2570488', 'n_tokens_mistral': 585, 'n_tokens_neox': 579, 'n_words': 112}