Code coverage report for lib/help/index.js

Statements: 91.67% (11 / 12)      Branches: 75% (3 / 4)      Functions: 100% (1 / 1)      Lines: 91.67% (11 / 12)     

All files » lib/help/ » index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 231     1   1 3 1 2           3   3 3 2   1    
var fs = require('fs'),
    path = require('path');
 
module.exports = help;
 
function help(item) {
  if (!item) {
    item = 'help';
  } else Iif (item === true) { // if used with -h or --help and no args
    item = 'help';
  }
 
  // cleanse the filename to only contain letters
  // aka: /\W/g but figured this was eaiser to read
  item = item.replace(/[^a-z]/gi, '');
 
  try {
    var body = fs.readFileSync(path.join(__dirname, '..', '..', 'doc', 'cli', item + '.txt'), 'utf8');
    return body;
  } catch (e) {
    return '"' + item + '" help can\'t be found';
  }
}