<commit_before>'use strict';

const Xvfb = require('xvfb'),
  Promise = require('bluebird');

Promise.promisifyAll(Xvfb.prototype);

function buildXvfbArgs({ display = 99, screen = 0, size }) {
  return {
    displayNum: display,
    silent: false,
    reuse: true,
    xvfb_args: ['-ac', '-nolisten', 'tcp', '-screen', screen, `${size}x24`]
  };
}

module.exports = {
  /**
   * @returns A promise for an xvfb instance. Pass it to stopXvfb.
   */
  startXvfb({ display = 99, size, options }) {
    let xvfbSize = size;
    if (options.browser === 'firefox') {
      const extraSizeInFirefox = 200;
      const viewPort = size.split('x');
      xvfbSize = Number(viewPort[0]) + extraSizeInFirefox + 'x' + viewPort[1];
    }
    const xvfbArgs = buildXvfbArgs({ display, size: xvfbSize });
    const xvfb = new Xvfb(xvfbArgs);
    return xvfb.startAsync().then(() => xvfb);
  },
  /**
   * @returns A promise that's resolved when xvfb has stopped.
   */
  stopXvfb(xvfb) {
    return Promise.resolve(xvfb).then(x => x.stopAsync());
  }
};
<commit_msg>Silent xvfb by default. If you enable -vv or higher, you will get the logs #371 (#372)<commit_after>'use strict';

const Xvfb = require('xvfb'),
  Promise = require('bluebird');

Promise.promisifyAll(Xvfb.prototype);

function buildXvfbArgs({ display = 99, screen = 0, size, silent }) {
  return {
    displayNum: display,
    silent,
    reuse: true,
    xvfb_args: ['-ac', '-nolisten', 'tcp', '-screen', screen, `${size}x24`]
  };
}

module.exports = {
  /**
   * @returns A promise for an xvfb instance. Pass it to stopXvfb.
   */
  startXvfb({ display = 99, size, options }) {
    let xvfbSize = size;
    if (options.browser === 'firefox') {
      const extraSizeInFirefox = 200;
      const viewPort = size.split('x');
      xvfbSize = Number(viewPort[0]) + extraSizeInFirefox + 'x' + viewPort[1];
    }
    const xvfbArgs = buildXvfbArgs({
      display,
      size: xvfbSize,
      silent: options.verbose >= 2 ? false : true
    });
    const xvfb = new Xvfb(xvfbArgs);
    return xvfb.startAsync().then(() => xvfb);
  },
  /**
   * @returns A promise that's resolved when xvfb has stopped.
   */
  stopXvfb(xvfb) {
    return Promise.resolve(xvfb).then(x => x.stopAsync());
  }
};

{'fraction_non_alphanumeric': 0.15975011155734048, 'fraction_numerical': 0.013833110218652387, 'mean_word_length': 3.16728624535316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '7188637', 'n_tokens_mistral': 832, 'n_tokens_neox': 807, 'n_words': 199}