Code coverage report for slap/lib/highlight/client.js

Statements: 92% (23 / 25)      Branches: 75% (3 / 4)      Functions: 75% (3 / 4)      Lines: 91.3% (21 / 23)      Ignored: none     

All files » slap/lib/highlight/ » client.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321 1 1 1 1   1 1 1 2           1 1 2 2 2 2 2 2     1   1   1 5  
var fork = require('child_process').fork;
var path = require('path');
var minimist = require('rc/node_modules/minimist');
var getRandomPort = require('get-random-port');
var Promise = require('bluebird');
 
var init = Promise.resolve();
var opts = minimist(process.execArgv);
var forkOpts = {silent: false};
Iif (['debug', 'debug-brk'].some(function (opt) { return opt in opts; })) {
  init = init
	  .then(getRandomPort)
	  .then(function (port) { forkOpts.execArgv = ['--debug=' + port]; });
}
 
var client;
function initClient () {
  var oldMessageListeners = client ? client.listeners('message') : [];
  client = fork(path.join(__dirname, 'server.js'), forkOpts);
  client.setMaxListeners(100);
  client.on('exit', initClient);
  oldMessageListeners.forEach(client.on.bind(client, 'message'));
  return client;
}
 
init = init.then(initClient);
 
module.exports = init;
 
var buckets = 0;
module.exports.getBucket = function () { return buckets++; };