resolveCustomFormatter.js 343 B

12345678910111213141516
  1. const fs = require('fs');
  2. const path = require('path');
  3. /**
  4. * @param {string} formatterPath
  5. * @returns {string}
  6. */
  7. module.exports = function resolveCustomFormatter(formatterPath) {
  8. const resolvedPath = path.resolve(formatterPath);
  9. if (fs.existsSync(resolvedPath)) {
  10. return resolvedPath;
  11. }
  12. return require.resolve(formatterPath);
  13. };