<commit_before>
var fs = require('fs');
var path = require('path');
var os = require('os');
var uuid = require('uuid');
var Fork = require('fork');
var duplexify = require('duplexify');
var after = require('after');
var extend = require('util')._extend;

//
// This will accept the following
// 1. A payload to merge in with the filename created
// 2. A path to the child process to fork that will do the processing
//

module.exports = StrongParent;

function StrongParent(options) {
  if (!(this instanceof StrongParent)) return new StrongParent(options);

  //
  // We just have a pth in this case, a child proc path
  //
  if (typeof options === 'string') {
    this.childPath = options;
    options = {};
  }

  this.filePath = options.filePath || path.join(os.tmpdir(), uuid.v4());
  this.childPath = this.childPath || options.path;
  this.childArgs = options.args;
  this.childEnv = options.env;
  this.payload = options.payload || {};

  this.stream = duplexify();

  //
  // Setup forking of child to do the processing
  //
  this.child = new Fork({
    path: this.childPath,
    args: this.childArgs,
    env: this.childEnv
  }).on('response', this._onRes.bind(this))
    .on('log', this.stream.emit.bind(this.stream, 'log'))
    .on('error', this.stream.emit.bind(this.stream, 'error'));

  this.writable = fs.createWriteStream(this.filePath)
    .on('finish', this._forkProc.bind(this));

  this.stream.setWritable(this.writable);

  return this.stream;
}

StrongParent.prototype._forkProc = function () {
  this.writable = null;
  this.child.fork(extend({ __file: this.filePath }, this.payload));
};<commit_msg>[fix] allow execPath and execArgv to be passed down via fork<commit_after>
var fs = require('fs');
var path = require('path');
var os = require('os');
var uuid = require('uuid');
var Fork = require('fork');
var duplexify = require('duplexify');
var after = require('after');
var extend = require('util')._extend;

//
// This will accept the following
// 1. A payload to merge in with the filename created
// 2. A path to the child process to fork that will do the processing
//

module.exports = StrongParent;

function StrongParent(options) {
  if (!(this instanceof StrongParent)) return new StrongParent(options);

  //
  // We just have a pth in this case, a child proc path
  //
  if (typeof options === 'string') {
    this.childPath = options;
    options = {};
  }

  this.filePath = options.filePath || path.join(os.tmpdir(), uuid.v4());
  this.childPath = this.childPath || options.path;
  this.childArgs = options.args;
  this.childEnv = options.env;
  this.execPath = options.execPath;
  this.execArgv = options.execArgv;
  this.payload = options.payload || {};

  this.stream = duplexify();

  //
  // Setup forking of child to do the processing
  //
  this.child = new Fork({
    path: this.childPath,
    args: this.childArgs,
    env: this.childEnv,
    execPath: this.execPath,
    execArgv: this.execArgv
  }).on('response', this._onRes.bind(this))
    .on('log', this.stream.emit.bind(this.stream, 'log'))
    .on('error', this.stream.emit.bind(this.stream, 'error'));

  this.writable = fs.createWriteStream(this.filePath)
    .on('finish', this._forkProc.bind(this));

  this.stream.setWritable(this.writable);

  return this.stream;
}

StrongParent.prototype._forkProc = function () {
  this.writable = null;
  this.child.fork(extend({ __file: this.filePath }, this.payload));
};
{'fraction_non_alphanumeric': 0.15416058394160584, 'fraction_numerical': 0.0017518248175182481, 'mean_word_length': 3.6739427012278307, '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': '6084575', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1082, 'n_words': 296}