index.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. Copyright 2012-2015, Yahoo Inc.
  3. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
  4. */
  5. var Reporter = require('./lib/reporter');
  6. /**
  7. * @module Exports
  8. */
  9. module.exports = {
  10. config: require('./lib/config'),
  11. cover: require('./lib/run-cover'),
  12. reports: require('./lib/run-reports'),
  13. instrument: require('./lib/run-instrument'),
  14. checkCoverage: require('./lib/run-check-coverage'),
  15. createReporter: function (cfg, opts) {
  16. return new Reporter(cfg, opts);
  17. },
  18. /**
  19. * asynchronously returns a function that can match filesystem paths.
  20. * The function returned in the callback may be passed directly as a `matcher`
  21. * to the functions in the `hook` module.
  22. *
  23. * When no options are passed, the match function is one that matches all JS
  24. * files under the current working directory except ones under `node_modules`
  25. *
  26. * Match patterns are `ant`-style patterns processed using the `fileset` library.
  27. * Examples not provided due to limitations in putting asterisks inside
  28. * jsdoc comments. Please refer to tests under `test/other/test-matcher.js`
  29. * for examples.
  30. *
  31. * @method matcherFor
  32. * @static
  33. * @param {Object} options Optional. Lookup options.
  34. * @param {String} [options.root] the root of the filesystem tree under
  35. * which to match files. Defaults to `process.cwd()`
  36. * @param {Array} [options.includes] an array of include patterns to match.
  37. * Defaults to all JS files under the root.
  38. * @param {Array} [options.excludes] and array of exclude patterns. File paths
  39. * matching these patterns will be excluded by the returned matcher.
  40. * Defaults to files under `node_modules` found anywhere under root.
  41. * @param {Function(err, matchFunction)} callback The callback that is
  42. * called with two arguments. The first is an `Error` object in case
  43. * of errors or a falsy value if there were no errors. The second
  44. * is a function that may be use as a matcher.
  45. */
  46. matcherFor: require('./lib/file-matcher').matcherFor,
  47. filesFor: require('./lib/file-matcher').filesFor
  48. };
  49. // export all the istanbul libraries as is so users don't have to take 5 deps
  50. // that are potentially inconsistent
  51. var DASH_PATTERN = /-([a-z])/g;
  52. function camelize(word) {
  53. return word.replace(DASH_PATTERN, function (match, lch) {
  54. return lch.toUpperCase();
  55. });
  56. }
  57. [ 'coverage', 'hook', 'instrument', 'report', 'source-maps'].forEach(function (k) {
  58. var mod = 'lib-' + k,
  59. prop = camelize(mod);
  60. module.exports[prop] = require('istanbul-' + mod);
  61. });
  62. module.exports.reportsImpl = require('istanbul-reports');